Issue with NoNodeAvailableException[None of the configured nodes are available:

Hi

I am developing my first Java client to access ES but got the NoNodeAvailableException[None of the configured nodes are available: error when try it and the issue is driving me crazy.

What I am doing is:

Settings settings = Settings.settingsBuilder()
.put("cluster.name", "mycluster")
.put("client.transport.ping_timeout", "30s")
.build();

    Client client = null;
    try {
        client = TransportClient.builder().settings(settings)
                .build()
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("myservername"), 9300));   // INT

        IndexRequestBuilder prepareIndex = client.prepareIndex("*", "log");

        ListenableActionFuture<IndexResponse> execute = prepareIndex.execute(); 

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

I have tried to increase the timeout even to 30 seconds but no success.
I saw on the net that a lot of people have had this problem but got no solution valid for me.

Thanks in advance.

PD: I actually used proper values on mycluster and myservername so this is not the error source.

Please format your code using </> icon. It will make your post more readable.

Common mistakes:

  • Forgot to define network.host on the machine
  • cluster.name changed
  • Firewall issues with port 9300

...

1 Like

Hi

Thanks for your reply.

I am sure that cluster.name remains unchanged.
What do you mean with network.host? Is it a property that I should add on my java code?

BTW: is there any special property that should I set on server to allow my java client that is placed out of the Elasticsearch server could get connected? Any property that should I check?

Thanks in advance.

I meant this: Network Settings | Elasticsearch Guide [2.3] | Elastic

Must be added on your nodes if you want them to be reachable from outside your server.

No. If you want to secure the transport layer, you need to use Shield / X-Pack (commercial subscription).

Note that in the next future, a REST java client will be released within 5.0. You can use it with elasticsearch 2.x as well.
Then you could add a NGinx layer to secure it. Still I think it would be much easier and with many other features OOTB to use X-Pack.

Thanks.

Seems that my problem is that I am trying to access the Amazon service instead of a real Elasticsearch running on an EC2 instance.

I was unable to find other way to access such service than the Kibana console.....

Oh? You are using Amazon Elasticsearch service?
AFAIK you can't do it with the transport client. Not sure they changed that.

Did you look at https://www.elastic.co/cloud by any chance?
It works with TransportClient and security OOTB.

Disclaimer: I work at elastic.

Hi

Well, my advise was to use ELK but somebody else decided to use the AWS Elasticsearch service... :slight_smile:

However, I wonder if it is possible to consume data from the Elasticsearch REST service from a Java application. I mean: is there a way to make specific queries to such service? Guide? Examples?

Thanks in advance.

You can wait for the Java REST client to be released. https://github.com/elastic/elasticsearch/tree/master/client/rest
There are already some alpha versions but not ready for production.
It's a low level client though. https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html

Also JEST: https://github.com/searchbox-io/Jest could help you.

Perfect.
Thank you!