Valeriy Valeriy - 4 years ago 247
Java Question

No Node Available Exception Elasticsearch 5.0.2

First for all, i'm sorry for my english.
I have a problem with Java API Transport Client. I have one master node and three data nodes. Version of my Elasticsearch is 5.0.2 and i use 5.0.2 API.

I try to connect to my cluster with Transport Client and then i response

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{8SAZOxXXTU61DuDDMN-vGw}{XX.XX.X.XXX}{XX.XX.X.XXX:9300}, {#transport#-2}{Fv3729YgTGClRBo5T2mWpA}{XX.XX.X.XXX}{XX.XX.X.XXX:9300}, {#transport#-3}{Fr98ApBbRv29Xv6Mc8L4TQ}{XX.XX.X.XXX}{XX.XX.X.XXX:9300}, {#transport#-4}{JOmpSH4LRzuP_XInxQtD9Q}{XX.XX.X.XXX}{XX.XX.X.XXX:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(
at org.elasticsearch.client.transport.TransportClientNodesService.execute(
at org.elasticsearch.client.transport.TransportProxyClient.execute(
at org.elasticsearch.client.transport.TransportClient.doExecute(
at org.elasticsearch.action.ActionRequestBuilder.execute(
at org.elasticsearch.action.ActionRequestBuilder.execute(
at org.elasticsearch.action.ActionRequestBuilder.get(
at nn.Main.main(

That is my code of client:


import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;

public class Main {
private static String[] hosts = new String[] {

private static final Settings settings = Settings.builder()
.put("", "myCluster")
.put("client.transport.sniff", true)
.put("transport.tcp.port", 9300)
.put("", "transport_client_user:changeme")
private static final String index = "myIndex";
private static final String type = "myType";
private static TransportClient client;

public static void main(String[] args) throws UnknownHostException {

InetSocketTransportAddress[] ista = new InetSocketTransportAddress[hosts.length];

for (int i = 0; i < hosts.length; i++) {
ista[i] = new InetSocketTransportAddress(InetAddress.getByName(hosts[i]), 9300);

client = new PreBuiltXPackTransportClient(settings).addTransportAddresses(ista);

SearchRequestBuilder rb = client
.setQuery(QueryBuilders.termQuery("_id", 3524598));

SearchResponse sResponse = rb.get();

Port for transport client - 9300, all my nodes communicate under this port. I saw a lot like my question, and i trying to follow the advice contained in them. But i have the same exception.

If need more information or any files or settings of my Elastic - i'm ready to answer.

If it is important this is content of elasticsearch.yml myCluster elastic-0 /var/db/elasticsearch
path.logs: /var/log/elasticsearch
path.scripts: /usr/local/libexec/elasticsearch _vmx0_

node.master: true false
node.ingest: false

node.attr.rack_id: rack_one
cluster.routing.allocation.awareness.attributes: rack_id

discovery.zen.minimum_master_nodes: 3 ["XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX"]

bootstrap.memory_lock: false

type: http
host: ["XX.XX.X.XXX:9200"]
auth.username: remote_monitor
auth.password: changeme

I tried to change
on just
, and disable
but without result.

I will be very gratefull for any help or ideas.

Answer Source

I found the reason for which i received "NoNodeAvailableException".

The reason is transport_client's role does not grant permission to view the data in all indices on default. And i will to built my role for the access to data in indices.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download