Skip to content
Advertisement

NoNodeAvailableException : None of the configured nodes are available

I’m trying to search from Elastic Search within my Java Web Service, here’s how I use now :

    Client client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.10.150"), 9200));
    SearchResponse searchResponse = client.prepareSearch().execute().actionGet();

The 1st line could work without an error, but when it goes to the 2nd line, the exception down below will occur :

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{TskPSVeBRR6CvCzP9EVhkQ}{192.168.10.150}{192.168.10.150:9200}]]

No matter I use 9200 or 9300 to set the port, the results are the same.

Also, I’ve tried to search from my .Net program using NEST, and it run just fine. Here’s how I tried :

    var node = new Uri("http://192.168.10.150:9200");
    var settings = new ConnectionSettings(node).DefaultIndex("iod-2017.03.08.*");
    _EsClient = new ElasticClient(settings);
    var index = String.Format("iod-{0}.{1:00}.{2:00}.*", item.TriggerTime.Year, item.TriggerTime.Month, item.TriggerTime.Day);
    var uniqueId = item.UniqueId.ToString();
    var result = _EsClient.Search<logs>(s => s.Index(index).Query(q => q.Match(t => t.Field(l => l.id).Query(uniqueId))));

Did I do anything(Firewall, version of library, method to call the API, etc) wrong with my Java program? My current Java version is 1.8.0.121, the version of Elastic Search and Transport Client are both 5.2. Thanks!

Advertisement

Answer

As discussed in comments,

If you are using a cluster name other than elasticsearch, then you need to update the same in settings.

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