# Cluster name not specified in java client and it is failing to communicate with cluster, no node available exceptio

**URL:** <https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868>\
**Category:** Elasticsearch\
**Created:** [November 8, 2017, 12:48pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868 "2017-11-08T12:48:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 12:48pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/1 "2017-11-08T12:48:22Z")

</div>

Hi,

I am not setting any cluster name in elasticsearch java client. it use to work with ES1.x. In 5.x yml file i am specifying path.data=/../data/{clustername} [path.data: /home/vagrant/elasticsearch-5.5.1/data/qa-elasticsearch]. it is creating a directory with cluster name and nodes directory in it.

My java client unable to identify this cluster. I am setting only port and host to client. This code use to work with ES1.x.

Below is my elasticsearch.yml

```auto
cluster.name: 'qa-elasticsearch'
node.name: 'localhost'

#################################### Paths ####################################

path.data: /home/vagrant/elasticsearch-5.5.1/data/qa-elasticsearch
path.logs: /home/vagrant/elasticsearch-5.5.1/logs
#path.conf: /usr/local/etc/elasticsearch

transport.host: localhost
network.host: 0.0.0.0
network.bind_host: '0.0.0.0'
transport.bind_host: 0.0.0.0
transport.tcp.port: 9300
http.port: 9200

bootstrap.system_call_filter: false
indices.query.bool.max_clause_count: 10240

```

client code:

```auto
@Autowired
    public CreateElasticSearchClient(@Qualifier("transportClient") Client client, SearchConfig searchConfig) {
        this.client = client;
        if (client instanceof TransportClient) {
            for (String hostName : searchConfig.searchServerHosts().split(",")) {
                try {
                    ((TransportClient) this.client).addTransportAddress(
                            new InetSocketTransportAddress(InetAddress.getByName(hostName), searchConfig.searchTransportPort()));
                } catch (UnknownHostException e) {
                    LOGGER.error(e.getMessage(),e);
                }
            }
        }
    }

```

getting No node available exception.

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 8, 2017, 1:46pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/2 "2017-11-08T13:46:26Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

I edited your post.

What do you have in `searchConfig` object?  
What are elasticsearch server logs please?

---

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 2:32pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/3 "2017-11-08T14:32:07Z")

</div>

Hi,

SearchConfig is my custom object which holds the host and port number of cluster.

Below exception i am getting in my java client console. Not seeing anything in cluster logs.

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{P4AAYjiKTq6PRgZePPMo3g}{localhost}{127.0.0.1:9300}]]  
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)  
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)  
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)  
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363)  
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)  
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:397)  
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1250)  
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.putMapping(AbstractClient.java:1497)  
at

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 8, 2017, 2:35pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/4 "2017-11-08T14:35:45Z")

</div>

I understand what `SearchConfig` is. I'd like to know what are the values you passed in it.

For logs, I'd like to see the logs when elasticsearch starts.

And please don't forget to format the code (or logs).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 8, 2017, 2:35pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/5 "2017-11-08T14:35:57Z")

</div>

I understand what `SearchConfig` is. I'd like to know what are the values you passed in it.

For logs, I'd like to see the logs when elasticsearch starts.

And please don't forget to format the code (or logs).

---

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 2:59pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/6 "2017-11-08T14:59:12Z")

</div>

SerchConfig has two values set in it.

search.server.hosts=localhost  
search.server.transport.port=9300

below is my log from ES5.4.1 logs:

```auto
[2017-11-08T14:42:10,253][INFO][o.e.n.Node] [localhost] initializing ...
[2017-11-08T14:42:10,407][INFO][o.e.e.NodeEnvironment] [localhost] using [1] data paths, mounts [[/ (/dev/mapper/VolGroup-lv_root)]], net usable_space [451.6gb], net total_space [489.2gb], spins? [possibly], types [ext4]
[2017-11-08T14:42:10,408][INFO][o.e.e.NodeEnvironment] [localhost] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-11-08T14:42:10,466][INFO][o.e.n.Node] [localhost] node name [localhost], node ID [CwCsYqDaSHSeU8OQdBJMqw]
[2017-11-08T14:42:10,466][INFO][o.e.n.Node] [localhost] version[5.5.1], pid[4608], build[19c13d0/2017-07-18T20:44:24.823Z], OS[Linux/2.6.32-358.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_112/25.112-b15]
[2017-11-08T14:42:10,472][INFO][o.e.n.Node] [localhost] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/media/sf_KC/elasticsearch5.x/elasticsearch-5.5.1]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [aggs-matrix-stats]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [ingest-common]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [lang-expression]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [lang-groovy]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [lang-mustache]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [lang-painless]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [parent-join]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [percolator]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [reindex]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [transport-netty3]
[2017-11-08T14:42:13,021][INFO][o.e.p.PluginsService] [localhost] loaded module [transport-netty4]
[2017-11-08T14:42:13,023][INFO][o.e.p.PluginsService] [localhost] no plugins loaded
[2017-11-08T14:42:16,504][INFO][o.e.d.DiscoveryModule] [localhost] using discovery type [zen]
[2017-11-08T14:42:17,659][INFO][o.e.n.Node] [localhost] initialized
[2017-11-08T14:42:17,660][INFO][o.e.n.Node] [localhost] starting ...
[2017-11-08T14:42:17,944][INFO][o.e.t.TransportService] [localhost] publish_address {127.0.0.1:9300}, bound_addresses {[::]:9300}
[2017-11-08T14:42:17,964][INFO][o.e.b.BootstrapChecks] [localhost] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-11-08T14:42:21,154][INFO][o.e.c.s.ClusterService] [localhost] new_master {localhost}{CwCsYqDaSHSeU8OQdBJMqw}{FcTm9pKzT6CtDCha--RwcA}{localhost}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-11-08T14:42:21,222][INFO][o.e.h.n.Netty4HttpServerTransport] [localhost] publish_address {10.0.2.15:9200}, bound_addresses {[::]:9200}
[2017-11-08T14:42:21,222][INFO][o.e.n.Node] [localhost] started
[2017-11-08T14:42:21,840][INFO][o.e.g.GatewayService] [localhost] recovered [6] indices into cluster_state
[2017-11-08T14:42:22,898][INFO][o.e.c.r.a.AllocationService] [localhost] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][1], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][4], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][0], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][3]] ...]).

```

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 8, 2017, 3:55pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/7 "2017-11-08T15:55:59Z")

</div>

Could you try with `127.0.0.1` as the address instead of `localhost`?

---

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 4:07pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/9 "2017-11-08T16:07:07Z")

</div>

Hi,

It was working with host as "locahost" and clustername in yml file as "elasticsearch".  
The only change i made here is, changed cluster name to "qa-elasticsearch" in yml file.

No where i am setting cluster name in java. previously and now also.

We are migrating from 1.x to 5.x. In 1.x also we were not setting the cluster name in java client. It is working (cluster name "qa-cluster").

As per your suggestion i changed it to 127.0.0.1. Getting same exception.

---

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 4:47pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/10 "2017-11-08T16:47:16Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/6/7/6700b565a210e96e33223fd0858816fddbc85553.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/9/4902fe0482f9a5b184bd4826052c435ab8ccb141.png)

"nodes" initialized in else block, but code not entering that else block. hence i am getting exception.

Further anylysis,

```auto
if (!ignoreClusterName && !clusterName.equals(livenessResponse.getClusterName())) {
                        logger.warn("node {} not part of the cluster {}, ignoring...", listedNode, clusterName);
                        newFilteredNodes.add(listedNode);
                    }

```

My code entering this if loop meaning it is not ignoring elastic cluster name(ignoreClusterName =false).  
below is my code to create client object.

```auto
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY);

```

---

<div class="post-metadata">

**Author:** ![basanagouda](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@basanagouda](https://discuss.elastic.co/u/basanagouda)\
**Post date:** [November 8, 2017, 4:58pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/11 "2017-11-08T16:58:58Z")

</div>

I solved the issue..

setting this property in Settings.  
"client.transport.ignore\_cluster\_name","true"

Thanks David Pilato for your support. Thank you so much.. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 6, 2017, 4:58pm UTC](https://discuss.elastic.co/t/cluster-name-not-specified-in-java-client-and-it-is-failing-to-communicate-with-cluster-no-node-available-exceptio/106868/12 "2017-12-06T16:58:59Z")

</div>

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