NoNodeException while connecting through Elasticsearch API- Java


(VijayKarthikeyan) #1

I have seen lot of topics in here with same title... but i couldnot get a proper solution. So am asking again.

I am getting a NoNodeException msg which is given below..

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{wGBsSw61TMm99QgcPcogLw}{10.242.244.170}{10.242.244.170:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:328)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:226)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:345)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62)
at elk.GETCallOnELK.callingELKWithGetMethod(GETCallOnELK.java:16)
at elk.ELKStackAPICallMain.main(ELKStackAPICallMain.java:9)

my code is

public class TransportClientConnection {

	public TransportClient callingElasticsearchAPI() throws ELKException {
		TransportClient client = null;
		try {
			client = new PreBuiltTransportClient(Settings.EMPTY)
					.addTransportAddress(new InetSocketTransportAddress(
							InetAddress.getByName("10.242.244.170"), 9300));
		} catch (UnknownHostException e) {
			throw new ELKException(e);
		}
		return client;
	}
}


public class GETCallOnELK {

	public void callingELKWithGetMethod() throws ELKException {

		TransportClientConnection creatingELKObjectForMethodCall = new TransportClientConnection();
		TransportClient clientForGET = creatingELKObjectForMethodCall
				.callingElasticsearchAPI();
		GetResponse response = clientForGET.prepareGet("logstash-2016.11.29",
				"EventLog", "AVivTmHdyF6Gdb7rRxGV").get();
		String indexName = response.getIndex();
		System.out.println("The Name of the index is :" + indexName);
	}
}

and a main to call these methods for a connection..

What possibly could cause this exception as I have no place in the API to mention the nodes or something.. I have a default cluster which is 'elasticsearch' and i have a single node..

Please help me solve this issue.


(David Pilato) #2

What are your server logs?

Did you bind the network host to something different than localhost?


(VijayKarthikeyan) #3

I did not get anything in the log as of now for API call...

and yes I changed the yml config file to make the IP of the server where ES is running instead of using the default localhost as I must also have access to ES from remote client machines where localhost wouldn't be helpful


(David Pilato) #4

Can you share your full logs?


(David Pilato) #5

BTW don't create a new Transport Client for every call. But I guess here it's only for test purpose.


(VijayKarthikeyan) #6

yes it is for testing whether this works for my configuration..

As I said i don't have any log generated for this call.. I checked the dates to see any updates on logs but nothing is there


(David Pilato) #7

So you don't want to share the logs?

I can't help. Sorry.


(VijayKarthikeyan) #8

i could not share the logs because i dont have any logs... not that i dont want to share..


(Isabel Drost-Fromm) #9

I think there's a misunderstanding here: What @dadoonet is asking for is not the logs for this particular API call, but the full logs of your elasticsearch cluster. It could be that your ES node didn't even start correctly, is configured to bind to the wrong network host etc.

Isabel


(VijayKarthikeyan) #10

I solved the problem myself mainec.. It is just the document that provided me wrong information, which made me code in different way.

It says that the settings does not need to configured in the API call when we use default cluster.. So i did it as the doc says. That was the problem.

I figured this out by just by adding the settings with my default cluster name mentioned in it.. and it worked without any problem.


(system) #11

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.