0
votes

Hi In my SpringBoot project i have configured elastic search using JPA. I am using ElasticsearchRepository for it. Now for the configuration when i am using localhost then everything works fine but when i am putting IP address then i am facing an exception-

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{lDnuVli1Rriy-9j1pdozZA}{27.101.12.99}{27.101.12.99:9300}] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) ~[elasticsearch-5.6.11.jar:5.6.11] at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) ~[elasticsearch-5.6.11.jar:5.6.11] at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.index(ElasticsearchTemplate.java:571) ~[spring-data-elasticsearch-3.0.10.RELEASE.jar:3.0.10.RELEASE] at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.save(AbstractElasticsearchRepository.java:156) ~[spring-data-elasticsearch-3.0.10.RELEASE.jar:3.0.10.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_151]

Code for initlizing Elastic Search -

@Bean
    public Client client() throws Exception {

        Settings  settings = Settings.builder()
                            .put("cluster.name",getElasticCluster())
                            .build();

        return new PreBuiltTransportClient(Settings.EMPTY)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(getElasticHost()),getElasticPort()));
    }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());
    }

elasticsearch: jest: proxy: host: 27.101.12.99 port: 9300

I had a lot of search but nothing is helpful in my case. So Please check and help.

1
Sounds like it might be a networking issue. Port 9300 is typically used for intra-node communication. Are you running a cluster? If you're just trying to use the REST API, then I expected to see your code calling port 9200. Can you curl the IP + port from that box?Joe Zack
yes , we are running a cluster. When i am wrting curl <Ip:9200> then it gives me result - { "name" : "7FNHH-9", "cluster_name" : "elasticsearch", "cluster_uuid" : "yghFr84lQZ6BLAIIfDOc3w", "version" : { "number" : "5.6.3", "build_hash" : "1a2f265", "build_date" : "2017-10-06T20:33:39.012Z", "build_snapshot" : false, "lucene_version" : "6.6.1" }, "tagline" : "You Know, for Search" } and when i am wrting curl<IP:9300> then its showing failed to connect.nitin tyagi
what version is your cluster? do you have the transport on port 9300 activated?P.J.Meisch
Is it possible that you start use 7.0.1 Elastic version ?user2264784

1 Answers

0
votes

The elasticsearch client in your application is joning the cluster using the transport protocoll. This approach is deprecated and already removed in recent releases. This said transport protocoll is not HTTP and your jest proxy probably fails to analyse/mock the data send. This is the reason why localhost works but jest proxy fails.

In order to have your application compatible with future releases of elasticsearch you should consider using the high level REST client without loosing any functionality for the spring app. And as a quick win you´ll be able to use jest again because the REST client is using HTTP to communicate with elasticsearch.

Please have a look on this for details about the client migration (I assumed the elasticsearch version based on the stacktrace, please double ckeck it) https://www.elastic.co/guide/en/elasticsearch/client/java-rest/5.6/java-rest-high-level-migration.html