NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{...}{127.0.0.1}{127.0.0.1:9300}]]
I have encountered same problem and i solved the mentioned issue by adding transport.host: localhost
property in elasticsearch.yml file.
After adding it, it works as expected. I hope it will help other reader of this thread.
Just for reference, I am using 7.2 while I was trying to use
org.elasticsearch.client:transport:5.5.1
and following code to connect to my local cluster, and same error popped into my face.
public static void main(String... args) {
TransportClient client = getClient();
SearchResponse response = client.prepareSearch("cars").execute().actionGet();
System.out.println(response);
}
private static TransportClient getClient() {
TransportClient client = null;
try {
client = new PreBuiltTransportClient(
Settings.builder().put("client.transport.sniff", true)
.put("cluster.name", "elasticsearch").build())
.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
client.listedNodes();
} catch (UnknownHostException e) {
}
return client;
}
As I checked the ES console, it's already warned me of the version issues
exception caught on transport layer [Netty4TcpChannel{localAddress=/127.0.0.1:9300, remoteAddress=/127.0.0.1:62723}], closing connection
java.lang.IllegalStateException: Received handshake message from unsupported version: [5.0.0] minimal compatible version is: [6.8.0]
So I just use the new version to fix the error.
org.elasticsearch.client:transport:7.2.0