Java client: Unable to connect to elastic cloud instance

I am trying to use Java Client to connect to my cloud instance. Here is my code, I am getting NoNodeAvailableException. Let me know if I am missing some thing. Appreciate any help.

try {
// Elastic Endpoint:

		String clusterName= "autospecs-drawings-dev";
		String esHost = "";
		int esPort = 9243;
		this.transportAddress = new InetSocketTransportAddress(InetAddress.getByName(esHost), esPort);

		Settings settings = Settings.builder()
				.put("", clusterName).
				put("", "TRACE").

		this.client = new PreBuiltTransportClient(settings).addTransportAddress(transportAddress);
		SearchResponse sr = client.prepareSearch("autospecs-drawings-0").get();
		long numHits = sr.getHits().getTotalHits();
		System.out.println("Number of hits is " + numHits);

	} catch (Exception e) {
		// TODO Auto-generated catch block
		esLogger.error("Exception during getting transportAddress", e);

Exception is this.
15:55:13.640 [main] ERROR - Exception during getting transportAddress
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{1NmEyI9ySICMCg-AuluqMA}{}{}]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable( ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.client.transport.TransportClientNodesService.execute( ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.client.transport.TransportProxyClient.execute( ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.client.transport.TransportClient.doExecute( ~[elasticsearch-5.5.0.jar:5.5.0]
at ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.action.ActionRequestBuilder.execute( ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.action.ActionRequestBuilder.execute( ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.action.ActionRequestBuilder.get( ~[elasticsearch-5.5.0.jar:5.5.0]
at com.pype.autospecs.util.ESUtil.( [bin/:?]
at com.pype.autospecs.util.ESUtil.( [bin/:?]

Try port 9343 instead.

I tried, but no luck. I get the same exception. Should I give username/password (elastic/) which has given me during sign up some where??

Hare is an example from the docs:

Hi Christian,
It looks too complicated to take that code. Also, shield is part of XPack as I have read some where. Would anyone have a readymade Java client code that connects/queries the elastic cloud node?

What about it is too complicated? It shows the headings and settings that need to be set in order to be able to connect to Elastic Cloud.

Hello Christian,
I am using 5.x client. When I use shield.user it says, unknown setting. On the other hand, if I use, its giving same error.

So, for 5.5 client, what is the setting property for given user name and password. I am able to connect using Curl command by giving -u option with username:passwd

Just realised that the example in the docs is for ES 2.x. There is however also a link to a 5.x example available on the page which it looks like you have found:

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