3

I am using Elasticsearch 7.1.1 with spring-boot 2.1.5. I downloaded Elasticsearch and run it. When I start the spring project I am getting an error. The is "failed to load Elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{rsi4dYt_RuOBGCdwUH3Cgg}{127.0.0.1}{127.0.0.1:9200}]". How can I runt it correctly

I used these configurations.

spring.elasticsearch.jest.multi-threaded=true
spring.main.allow-bean-definition-overriding=true
spring.data.elasticsearch.cluster-nodes=localhost:9200
spring.data.elasticsearch.repositories.enabled=true
spring.elasticsearch.jest.uris=http://localhost:9200
spring.elasticsearch.jest.connection-timeout=3s
spring.elasticsearch.rest.uris=http://localhost:9200
spring.data.elasticsearch.cluster-name=elasticsearch

and

@Configuration
@EnableElasticsearchRepositories(basePackages = 
"com.example.elasticsearch.repository")
public class ElasticSearchConfiguration {
 @Bean
 public Client client() throws UnknownHostException {
    Settings settings = Settings.builder()
            .put("client.transport.sniff", true)
            .put("cluster.name", "elasticsearch").build();
    @SuppressWarnings("resource")
    TransportClient client = new PreBuiltTransportClient(settings)
            .addTransportAddress(new 
 TransportAddress(InetAddress.getByName("127.0.0.1"), 9200));

    return client;
}

@Bean
public ElasticsearchOperations elasticsearchTemplate() throws 
UnknownHostException {
    return new ElasticsearchTemplate(client());
   }
}
  • Maybe mixing `localhost` and `127.0.0.1` is a problem. This link might be helpful: https://stackoverflow.com/questions/25912572/java-elasticsearch-none-of-the-configured-nodes-are-available – Michal W Jun 16 '19 at 10:48
  • I tried both ways but did not help. I think maybe need to configure dependency version spring-boot and Elasticsearch – Nasibulloh Yandashev Jun 16 '19 at 10:53
  • Have You successfully connected to elasticsearch from rest client / browser? Can You post the full stacktrace? – Michal W Jun 16 '19 at 10:56
  • Yes. { "name" : "lenovo", "cluster_name" : "elasticsearch", "cluster_uuid" : "l3iS7059R9qpBtqn365tIw", "version" : { "number" : "7.1.1", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "7a013de", "build_date" : "2019-05-23T14:04:00.380842Z", "build_snapshot" : false, "lucene_version" : "8.0.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } – Nasibulloh Yandashev Jun 16 '19 at 10:57
  • This JSON file I got via the browser – Nasibulloh Yandashev Jun 16 '19 at 10:57
  • How many nodes do You have on ES? Please try to remove/comment settings part and build Your client as described here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.3//transport-client.html You can also try to connect using port 9300. I'll try to find my configuration for previous project. – Michal W Jun 16 '19 at 11:09
  • The port 9300 is not available current time. – Nasibulloh Yandashev Jun 16 '19 at 11:12
  • Can You show full output of GET request to `_nodes/` endpoint? – Michal W Jun 16 '19 at 11:17
  • It is too long to fill the comment field – Nasibulloh Yandashev Jun 16 '19 at 12:14
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/195060/discussion-between-nasibulloh-yandashev-and-www). – Nasibulloh Yandashev Jun 17 '19 at 12:00

1 Answers1

0

I think were you are getting it wrong is using port = 9200 try to use port = 9300. From connecting to Elastic Search server from your application the port number 9300 is used and not 9200.

Anana Aristotle
  • 344
  • 4
  • 12