Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: No node available

StackOverflow https://stackoverflow.com/questions/23242729

سؤال

I am trying index using below Java code in elastic search.. I gave my machine Ip in the code .It is unable to connect to node. It is giving error like below :

Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: No node available at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219) at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106) at org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:82) at org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:330) at org.elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:314) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59) at test.test1.main(test1.java:30)

Code I am using:

public static void main(String[] args) {

    String json = "{" +         
                    "\"user\":\"AMaresh\"," +         
                    "\"postDate\":\"2014-04-23\"," + 
                    "\"message\":\"trying out Elasticsearch\"" +
                    "}";  


    Settings settings = ImmutableSettings.settingsBuilder().put("elasticsearch", "elasticsearch").build();
    TransportClient transportClient = new TransportClient(settings);

    Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("10.210.51.207",9300));

    IndexResponse response = client.prepareIndex("Cricket", "cric", "1").setSource(json).execute().actionGet();
    //List<String> matches = response.matches();
    System.out.println(response);
    System.out.println("finished");

I have checked ports are open in the machine.

Can anybody help me understanding the problem.

Thanks in advance

هل كانت مفيدة؟

المحلول

I think the problem in mentioning cluster name.. Use lik following

    Settings settings =               ImmutableSettings.settingsBuilder()
   .put("cluster.name", "elasticsearch").build();

Hope it helps..!

نصائح أخرى

This answer https://stackoverflow.com/a/25053586/3827220 to a similar problem, is applicable to the error message you're seeing.

Check to make sure you are using the same major version on the client side and the cluster side.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top