# Elasticsearch - node client does not connect to cluster

**URL:** <https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714>\
**Category:** Elasticsearch\
**Created:** [March 17, 2015, 3:25pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714 "2015-03-17T15:25:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 17, 2015, 3:25pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/1 "2015-03-17T15:25:29Z")

</div>

I have one physical server and I work only on it (no other servers).  
At this server I have running elastic 1.4.2 - I use this version as this is the last version elastic osgi bundle is ready for. Also at this server I have glassfish 4.1 as java-ee server.  
I run elastic node client inside my java-ee application. And I do it this way:  
Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
Client client = node.client();  
GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
Map\<String,Object\> source = getResponse.getSource();  
System.out.println("------------------------------");  
System.out.println("Index: "+ getResponse.getIndex());  
System.out.println("Type: "+ getResponse.getType());  
System.out.println("Id: "+ getResponse.getId());  
System.out.println("Version: "+ getResponse.getVersion());  
System.out.println(source);

In log I see the following:

> [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO] [org.elasticsearch.discovery] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue: 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]  
> [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO] [org.elasticsearch.cluster.service] [tid: \_ThreadID=128 \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]] [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com) ][local[1]]{local=true}}, removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com) ][local[1]]{local=true},}, reason: local-disco-initial\_connect(master)]]  
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]  
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]  
> and I get this exeption: ...  
> Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing  
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)  
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)  
> at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)  
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:139)  
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:116)  
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)  
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)  
> at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)  
> at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)  
> at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)  
> at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)  
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)

So it can't find the index - my.index-0.2.2. However this index exists! Besides, when I do curl -XGET ' [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1) ' I see there only one node and this is not SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I create using java API creates new cluster and dosn't connect to my existing cluster - that's why it says - it's master. Or I don't understand something I have problem with code. Besides I've checked tha name of cluster it's elasticsearch . So, how can I connect to my existing elasticsearch cluster?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426605929.302531214%40f430.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426605929.302531214%40f430.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_Mefford](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Aaron\_Mefford](https://discuss.elastic.co/u/Aaron_Mefford)\
**Post date:** [March 17, 2015, 4:46pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/2 "2015-03-17T16:46:39Z")

</div>

Is there a reason not to just specify the IP address and to try and rely on  
multicast?

I realize this is all on one node as you have stated that, but that seems  
even more reason that it would be little issue to specify the IP. While  
multicast makes it easy to stand up a cluster in an ideal situation, my  
experience has been that it leads to more problems down the road, and  
things generally work better when not using multicast. I heard the same  
suggestion repeatedly at Elastic{on}.

Aaron

On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:

> I have one physical server and I work only on it (no other servers).
> 
> At this server I have running elastic 1.4.2 - I use this version as this  
> is the last version elastic osgi bundle is ready for. Also at this server I  
> have glassfish 4.1 as java-ee server.
> 
> I run elastic node client inside my java-ee application. And I do it this  
> way:
> 
> Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> Client client = node.client();  
> GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> Map\<String,Object\> source = getResponse.getSource();  
> System.out.println("------------------------------");  
> System.out.println("Index: "+ getResponse.getIndex());  
> System.out.println("Type: "+ getResponse.getType());  
> System.out.println("Id: "+ getResponse.getId());  
> System.out.println("Version: "+ getResponse.getVersion());  
> System.out.println(source);
> 
> In log I see the following:
> 
> [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.discovery] [tid: \_ThreadID=30  
> \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue:  
> 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]
> 
> [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.cluster.service] [tid: \_ThreadID=128  
> \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]]  
> [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new  
> [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com)][local[1]]{local=true}},  
> removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com)][local[1]]{local=true},},  
> reason: local-disco-initial\_connect(master)]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address  
> {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]
> 
> and I get this exeption: ...
> 
> ```
> Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)
> at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:139)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:116)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)
> at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)
> at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)
> at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
> at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> 
> ```
> 
> So it can't find the index - my.index-0.2.2. However this index exists!  
> Besides, when I do curl -XGET '  
> [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1)' I see there only one node  
> and this _is not_ SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I  
> create using java API creates new cluster and dosn't connect to my existing  
> cluster - that's why it says - it's master. Or I don't understand something  
> I have problem with code. Besides I've checked tha name of cluster it's  
> elasticsearch. So, how can I connect to my existing elasticsearch cluster?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 17, 2015, 5:18pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/3 "2015-03-17T17:18:18Z")

</div>

We do recommend to use unicast in production.

On 17 March 2015 at 09:46, [aaron@definemg.com](mailto:aaron@definemg.com) wrote:

> Is there a reason not to just specify the IP address and to try and rely  
> on multicast?
> 
> I realize this is all on one node as you have stated that, but that seems  
> even more reason that it would be little issue to specify the IP. While  
> multicast makes it easy to stand up a cluster in an ideal situation, my  
> experience has been that it leads to more problems down the road, and  
> things generally work better when not using multicast. I heard the same  
> suggestion repeatedly at Elastic{on}.
> 
> Aaron
> 
> On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> 
> > I have one physical server and I work only on it (no other servers).
> > 
> > At this server I have running elastic 1.4.2 - I use this version as this  
> > is the last version elastic osgi bundle is ready for. Also at this server I  
> > have glassfish 4.1 as java-ee server.
> > 
> > I run elastic node client inside my java-ee application. And I do it this  
> > way:
> > 
> > Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> > Client client = node.client();  
> > GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> > Map\<String,Object\> source = getResponse.getSource();  
> > System.out.println("------------------------------");  
> > System.out.println("Index: "+ getResponse.getIndex());  
> > System.out.println("Type: "+ getResponse.getType());  
> > System.out.println("Id: "+ getResponse.getId());  
> > System.out.println("Version: "+ getResponse.getVersion());  
> > System.out.println(source);
> > 
> > In log I see the following:
> > 
> > [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO]   
> > [org.elasticsearch.discovery] [tid: \_ThreadID=30  
> > \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue:  
> > 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]
> > 
> > [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO]   
> > [org.elasticsearch.cluster.service] [tid: \_ThreadID=128  
> > \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]]  
> > [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new  
> > [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com)][local[1]]{local=true}},  
> > removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com)  
> > ][local[1]]{local=true},}, reason: local-disco-initial\_connect(master)]]
> > 
> > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> > [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> > [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address  
> > {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]
> > 
> > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> > [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> > [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]
> > 
> > and I get this exeption: ...
> > 
> > ```
> > Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing
> > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)
> > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)
> > at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)
> > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:139)
> > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:116)
> > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)
> > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)
> > at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)
> > at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)
> > at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
> > at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
> > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
> > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> > 
> > ```
> > 
> > So it can't find the index - my.index-0.2.2. However this index exists!  
> > Besides, when I do curl -XGET '[http://localhost:9200/\_](http://localhost:9200/_)  
> > cluster/state?pretty=1' I see there only one node and this _is not_  
> > SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I create using java API  
> > creates new cluster and dosn't connect to my existing cluster - that's why  
> > it says - it's master. Or I don't understand something I have problem with  
> > code. Besides I've checked tha name of cluster it's elasticsearch. So,  
> > how can I connect to my existing elasticsearch cluster?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9vWq4qv0N\_uCego5Q%3DTTriCRcuVKp8UVLJoiWh75TuTg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9vWq4qv0N_uCego5Q%3DTTriCRcuVKp8UVLJoiWh75TuTg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 17, 2015, 5:19pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/4 "2015-03-17T17:19:10Z")

</div>

I am quite newbie to elactis. Could you explain with java code what you mean?

Вторник, 17 марта 2015, 9:46 -07:00 от [aaron@definemg.com](mailto:aaron@definemg.com):

> Is there a reason not to just specify the IP address and to try and rely on multicast?
> 
> I realize this is all on one node as you have stated that, but that seems even more reason that it would be little issue to specify the IP. While multicast makes it easy to stand up a cluster in an ideal situation, my experience has been that it leads to more problems down the road, and things generally work better when not using multicast. I heard the same suggestion repeatedly at Elastic{on}.
> 
> Aaron
> 
> On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> 
> > I have one physical server and I work only on it (no other servers).  
> > At this server I have running elastic 1.4.2 - I use this version as this is the last version elastic osgi bundle is ready for. Also at this server I have glassfish 4.1 as java-ee server.  
> > I run elastic node client inside my java-ee application. And I do it this way:  
> > Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> > Client client = node.client();  
> > GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> > Map\<String,Object\> source = getResponse.getSource();  
> > System.out.println("------------------------------");  
> > System.out.println("Index: "+ getResponse.getIndex());  
> > System.out.println("Type: "+ getResponse.getType());  
> > System.out.println("Id: "+ getResponse.getId());  
> > System.out.println("Version: "+ getResponse.getVersion());  
> > System.out.println(source);
> > 
> > In log I see the following:
> > 
> > > [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO] [org.elasticsearch.discovery] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue: 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]  
> > > [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO] [org.elasticsearch.cluster.service] [tid: \_ThreadID=128 \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]] [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com) ][local[1]]{local=true}}, removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com) ][local[1]]{local=true},}, reason: local-disco-initial\_connect(master)]]  
> > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]  
> > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]  
> > > and I get this exeption: ...  
> > > Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing  
> > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)  
> > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)  
> > > at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)  
> > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:139)  
> > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:116)  
> > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)  
> > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)  
> > > at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)  
> > > at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)  
> > > at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)  
> > > at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)  
> > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> > 
> > So it can't find the index - my.index-0.2.2. However this index exists! Besides, when I do curl -XGET ' [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1) ' I see there only one node and this is not SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I create using java API creates new cluster and dosn't connect to my existing cluster - that's why it says - it's master. Or I don't understand something I have problem with code. Besides I've checked tha name of cluster it's elasticsearch. So, how can I connect to my existing elasticsearch cluster?  
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com) .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426612750.154168089%40f37.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426612750.154168089%40f37.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_Mefford](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Aaron\_Mefford](https://discuss.elastic.co/u/Aaron_Mefford)\
**Post date:** [March 17, 2015, 5:26pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/5 "2015-03-17T17:26:31Z")

</div>

This is what I use in my code, not sure how correct it is given the abysmal  
state of the the Java API documentation.

import org.elasticsearch.common.settings.Settings;  
import org.elasticsearch.common.settings.ImmutableSettings;  
import org.elasticsearch.client.Client;  
import org.elasticsearch.client.transport.TransportClient;  
import org.elasticsearch.common.transport.InetSocketTransportAddress;

```
    Settings settings = ImmutableSettings.settingsBuilder()
                            .put("cluster.name", elasticClusterName)
                            .put("client.transport.sniff",

```

true).build();

```
    esClient = new TransportClient(settings)
        .addTransportAddress(new

```

InetSocketTransportAddress(elasticHost,elasticPort));

On Tue, Mar 17, 2015 at 11:19 AM, Александр Свиридов [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru)  
wrote:

> I am quite newbie to elactis. Could you explain with java code what you  
> mean?
> 
> Вторник, 17 марта 2015, 9:46 -07:00 от [aaron@definemg.com](mailto:aaron@definemg.com):
> 
> Is there a reason not to just specify the IP address and to try and  
> rely on multicast?
> 
> I realize this is all on one node as you have stated that, but that seems  
> even more reason that it would be little issue to specify the IP. While  
> multicast makes it easy to stand up a cluster in an ideal situation, my  
> experience has been that it leads to more problems down the road, and  
> things generally work better when not using multicast. I heard the same  
> suggestion repeatedly at Elastic{on}.
> 
> Aaron
> 
> On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> 
> I have one physical server and I work only on it (no other servers).
> 
> At this server I have running elastic 1.4.2 - I use this version as this  
> is the last version elastic osgi bundle is ready for. Also at this server I  
> have glassfish 4.1 as java-ee server.
> 
> I run elastic node client inside my java-ee application. And I do it this  
> way:
> 
> Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> Client client = node.client();  
> GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> Map\<String,Object\> source = getResponse.getSource();  
> System.out.println("------------------------------");  
> System.out.println("Index: "+ getResponse.getIndex());  
> System.out.println("Type: "+ getResponse.getType());  
> System.out.println("Id: "+ getResponse.getId());  
> System.out.println("Version: "+ getResponse.getVersion());  
> System.out.println(source);
> 
> In log I see the following:
> 
> [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.discovery] [tid: \_ThreadID=30  
> \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue:  
> 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]
> 
> [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.cluster.service] [tid: \_ThreadID=128  
> \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]]  
> [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new  
> [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com)][local[1]]{local=true}},  
> removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com)][local[1]]{local=true},},  
> reason: local-disco-initial\_connect(master)]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address  
> {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]
> 
> and I get this exeption: ...
> 
> ```
> Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)
> at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:139)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:116)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)
> at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)
> at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)
> at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
> at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> 
> ```
> 
> So it can't find the index - my.index-0.2.2. However this index exists!  
> Besides, when I do curl -XGET '  
> [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1)' I see there only one node  
> and this _is not_ SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I  
> create using java API creates new cluster and dosn't connect to my existing  
> cluster - that's why it says - it's master. Or I don't understand something  
> I have problem with code. Besides I've checked tha name of cluster it's  
> elasticsearch. So, how can I connect to my existing elasticsearch cluster?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com)  
> [https://e.mail.ru/compose/?mailto=mailto%3Aelasticsearch%2Bunsubscribe@googlegroups.com](https://e.mail.ru/compose/?mailto=mailto%3aelasticsearch%2bunsubscribe@googlegroups.com)  
> .  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 17, 2015, 5:42pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/6 "2015-03-17T17:42:19Z")

</div>

Thank you. I did this way:

Settings settings = ImmutableSettings.settingsBuilder()  
.put("cluster.name", "elasticsearch")  
.put("client.transport.sniff", true).build();

```
    Client client = new TransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress("localhost",9300));

```

And everything works fine. So, both cluster and index exist.

However, as I understand it is not node client. What you sugget is transport client. Now I want to understand how to make node client work.

Вторник, 17 марта 2015, 11:26 -06:00 от Aaron Mefford [aaron@definemg.com](mailto:aaron@definemg.com):

> This is what I use in my code, not sure how correct it is given the abysmal state of the the Java API documentation.
> 
> import org.elasticsearch.common.settings.Settings;  
> import org.elasticsearch.common.settings.ImmutableSettings;  
> import org.elasticsearch.client.Client;  
> import org.elasticsearch.client.transport.TransportClient;  
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
> 
> ```
> Settings settings = ImmutableSettings.settingsBuilder()
> .put(" cluster.name ", elasticClusterName)
> .put("client.transport.sniff", true).build();
> 
> esClient = new TransportClient(settings)
> .addTransportAddress(new InetSocketTransportAddress(elasticHost,elasticPort));
> 
> ```
> 
> On Tue, Mar 17, 2015 at 11:19 AM, Александр Свиридов \< [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) \> wrote:
> 
> > I am quite newbie to elactis. Could you explain with java code what you mean?
> > 
> > Вторник, 17 марта 2015, 9:46 -07:00 от [aaron@definemg.com](mailto:aaron@definemg.com) :
> > 
> > > Is there a reason not to just specify the IP address and to try and rely on multicast?
> > > 
> > > I realize this is all on one node as you have stated that, but that seems even more reason that it would be little issue to specify the IP. While multicast makes it easy to stand up a cluster in an ideal situation, my experience has been that it leads to more problems down the road, and things generally work better when not using multicast. I heard the same suggestion repeatedly at Elastic{on}.
> > > 
> > > Aaron
> > > 
> > > On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> > > 
> > > > I have one physical server and I work only on it (no other servers).  
> > > > At this server I have running elastic 1.4.2 - I use this version as this is the last version elastic osgi bundle is ready for. Also at this server I have glassfish 4.1 as java-ee server.  
> > > > I run elastic node client inside my java-ee application. And I do it this way:  
> > > > Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> > > > Client client = node.client();  
> > > > GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> > > > Map\<String,Object\> source = getResponse.getSource();  
> > > > System.out.println("------------------------------");  
> > > > System.out.println("Index: "+ getResponse.getIndex());  
> > > > System.out.println("Type: "+ getResponse.getType());  
> > > > System.out.println("Id: "+ getResponse.getId());  
> > > > System.out.println("Version: "+ getResponse.getVersion());  
> > > > System.out.println(source);
> > > > 
> > > > In log I see the following:
> > > > 
> > > > > [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO] [org.elasticsearch.discovery] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue: 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]  
> > > > > [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO] [org.elasticsearch.cluster.service] [tid: \_ThreadID=128 \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]] [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com) ][local[1]]{local=true}}, removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com) ][local[1]]{local=true},}, reason: local-disco-initial\_connect(master)]]  
> > > > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]  
> > > > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]  
> > > > > and I get this exeption: ...  
> > > > > Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing  
> > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)  
> > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)  
> > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)  
> > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:139)  
> > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:116)  
> > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)  
> > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)  
> > > > > at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)  
> > > > > at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)  
> > > > > at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)  
> > > > > at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)  
> > > > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> > > > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> > > > 
> > > > So it can't find the index - my.index-0.2.2. However this index exists! Besides, when I do curl -XGET ' [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1) ' I see there only one node and this is not SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I create using java API creates new cluster and dosn't connect to my existing cluster - that's why it says - it's master. Or I don't understand something I have problem with code. Besides I've checked tha name of cluster it's elasticsearch. So, how can I connect to my existing elasticsearch cluster?  
> > > > --  
> > > > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> > > > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com) .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com) .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426614139.905053331%40f89.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426614139.905053331%40f89.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_Mefford](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Aaron\_Mefford](https://discuss.elastic.co/u/Aaron_Mefford)\
**Post date:** [March 17, 2015, 5:56pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/7 "2015-03-17T17:56:16Z")

</div>

What is the advantage you expect from using the Node client, especially in  
a single node environment?

With client.transport.sniff true it should discover the other nodes, if  
other nodes exist.

On Tue, Mar 17, 2015 at 11:42 AM, Александр Свиридов [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru)  
wrote:

> Thank you. I did this way:
> 
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("cluster.name", "elasticsearch")  
> .put("client.transport.sniff",  
> true).build();
> 
> ```
> Client client = new TransportClient(settings)
> .addTransportAddress(new
> 
> ```
> 
> InetSocketTransportAddress("localhost",9300));
> 
> And everything works fine. So, both cluster and index exist.
> 
> However, as I understand it is not node client. What you sugget is  
> transport client. Now I want to understand how to make node client work.
> 
> Вторник, 17 марта 2015, 11:26 -06:00 от Aaron Mefford \<[aaron@definemg.com](mailto:aaron@definemg.com)
> 
> > :
> 
> This is what I use in my code, not sure how correct it is given the  
> abysmal state of the the Java API documentation.
> 
> import org.elasticsearch.common.settings.Settings;  
> import org.elasticsearch.common.settings.ImmutableSettings;  
> import org.elasticsearch.client.Client;  
> import org.elasticsearch.client.transport.TransportClient;  
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
> 
> ```
> Settings settings = ImmutableSettings.settingsBuilder()
> .put("cluster.name", elasticClusterName)
> .put("client.transport.sniff",
> 
> ```
> 
> true).build();
> 
> ```
> esClient = new TransportClient(settings)
> .addTransportAddress(new
> 
> ```
> 
> InetSocketTransportAddress(elasticHost,elasticPort));
> 
> On Tue, Mar 17, 2015 at 11:19 AM, Александр Свиридов \<[ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru)  
> [https://e.mail.ru/compose/?mailto=mailto%3Aooo\_saturn7@mail.ru](https://e.mail.ru/compose/?mailto=mailto%3aooo_saturn7@mail.ru)\> wrote:
> 
> I am quite newbie to elactis. Could you explain with java code what you  
> mean?
> 
> Вторник, 17 марта 2015, 9:46 -07:00 от [aaron@definemg.com](mailto:aaron@definemg.com)  
> [https://e.mail.ru/compose/?mailto=mailto%3Aaaron@definemg.com](https://e.mail.ru/compose/?mailto=mailto%3aaaron@definemg.com):
> 
> Is there a reason not to just specify the IP address and to try and  
> rely on multicast?
> 
> I realize this is all on one node as you have stated that, but that seems  
> even more reason that it would be little issue to specify the IP. While  
> multicast makes it easy to stand up a cluster in an ideal situation, my  
> experience has been that it leads to more problems down the road, and  
> things generally work better when not using multicast. I heard the same  
> suggestion repeatedly at Elastic{on}.
> 
> Aaron
> 
> On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> 
> I have one physical server and I work only on it (no other servers).
> 
> At this server I have running elastic 1.4.2 - I use this version as this  
> is the last version elastic osgi bundle is ready for. Also at this server I  
> have glassfish 4.1 as java-ee server.
> 
> I run elastic node client inside my java-ee application. And I do it this  
> way:
> 
> Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> Client client = node.client();  
> GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> Map\<String,Object\> source = getResponse.getSource();  
> System.out.println("------------------------------");  
> System.out.println("Index: "+ getResponse.getIndex());  
> System.out.println("Type: "+ getResponse.getType());  
> System.out.println("Id: "+ getResponse.getId());  
> System.out.println("Version: "+ getResponse.getVersion());  
> System.out.println(source);
> 
> In log I see the following:
> 
> [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.discovery] [tid: \_ThreadID=30  
> \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue:  
> 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]
> 
> [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.cluster.service] [tid: \_ThreadID=128  
> \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]]  
> [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new  
> [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com)][local[1]]{local=true}},  
> removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com)][local[1]]{local=true},},  
> reason: local-disco-initial\_connect(master)]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address  
> {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]
> 
> [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO]   
> [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)]  
> [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]
> 
> and I get this exeption: ...
> 
> ```
> Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)
> at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)
> at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:139)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.<init>(TransportShardSingleOperationAction.java:116)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)
> at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)
> at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)
> at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)
> at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
> at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> 
> ```
> 
> So it can't find the index - my.index-0.2.2. However this index exists!  
> Besides, when I do curl -XGET '  
> [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1)' I see there only one node  
> and this _is not_ SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I  
> create using java API creates new cluster and dosn't connect to my existing  
> cluster - that's why it says - it's master. Or I don't understand something  
> I have problem with code. Besides I've checked tha name of cluster it's  
> elasticsearch. So, how can I connect to my existing elasticsearch cluster?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com)  
> [https://e.mail.ru/compose/?mailto=mailto%3Aelasticsearch%2Bunsubscribe@googlegroups.com](https://e.mail.ru/compose/?mailto=mailto%3aelasticsearch%2bunsubscribe@googlegroups.com)  
> .  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com)  
> [https://e.mail.ru/compose/?mailto=mailto%3Aelasticsearch%2Bunsubscribe@googlegroups.com](https://e.mail.ru/compose/?mailto=mailto%3aelasticsearch%2bunsubscribe@googlegroups.com)  
> .  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEp6FjLMnrb1GcyDhCfFL794zwFGOvMHJG4qGCc%3DYZ769g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEp6FjLMnrb1GcyDhCfFL794zwFGOvMHJG4qGCc%3DYZ769g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 17, 2015, 6:05pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/8 "2015-03-17T18:05:33Z")

</div>

I agree with you that in single node environment only transport layer should be used. But I want to know how to make node client work because maybe I will need it in future and I want to know what I can do with elastic java api.

Вторник, 17 марта 2015, 11:56 -06:00 от Aaron Mefford [aaron@definemg.com](mailto:aaron@definemg.com):

> What is the advantage you expect from using the Node client, especially in a single node environment?
> 
> With client.transport.sniff true it should discover the other nodes, if other nodes exist.
> 
> On Tue, Mar 17, 2015 at 11:42 AM, Александр Свиридов \< [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) \> wrote:
> 
> > Thank you. I did this way:
> > 
> > Settings settings = ImmutableSettings.settingsBuilder()  
> > .put(" cluster.name ", "elasticsearch")  
> > .put("client.transport.sniff", true).build();
> > 
> > ```
> > Client client = new TransportClient(settings)
> > .addTransportAddress(new InetSocketTransportAddress("localhost",9300));
> > 
> > ```
> > 
> > And everything works fine. So, both cluster and index exist.
> > 
> > However, as I understand it is not node client. What you sugget is transport client. Now I want to understand how to make node client work.
> > 
> > Вторник, 17 марта 2015, 11:26 -06:00 от Aaron Mefford \< [aaron@definemg.com](mailto:aaron@definemg.com) \>:
> > 
> > > This is what I use in my code, not sure how correct it is given the abysmal state of the the Java API documentation.
> > > 
> > > import org.elasticsearch.common.settings.Settings;  
> > > import org.elasticsearch.common.settings.ImmutableSettings;  
> > > import org.elasticsearch.client.Client;  
> > > import org.elasticsearch.client.transport.TransportClient;  
> > > import org.elasticsearch.common.transport.InetSocketTransportAddress;
> > > 
> > > ```
> > > Settings settings = ImmutableSettings.settingsBuilder()
> > > .put(" cluster.name ", elasticClusterName)
> > > .put("client.transport.sniff", true).build();
> > > 
> > > esClient = new TransportClient(settings)
> > > .addTransportAddress(new InetSocketTransportAddress(elasticHost,elasticPort));
> > > 
> > > ```
> > > 
> > > On Tue, Mar 17, 2015 at 11:19 AM, Александр Свиридов \< [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) \> wrote:
> > > 
> > > > I am quite newbie to elactis. Could you explain with java code what you mean?
> > > > 
> > > > Вторник, 17 марта 2015, 9:46 -07:00 от [aaron@definemg.com](mailto:aaron@definemg.com) :
> > > > 
> > > > > Is there a reason not to just specify the IP address and to try and rely on multicast?
> > > > > 
> > > > > I realize this is all on one node as you have stated that, but that seems even more reason that it would be little issue to specify the IP. While multicast makes it easy to stand up a cluster in an ideal situation, my experience has been that it leads to more problems down the road, and things generally work better when not using multicast. I heard the same suggestion repeatedly at Elastic{on}.
> > > > > 
> > > > > Aaron
> > > > > 
> > > > > On Tuesday, March 17, 2015 at 9:25:46 AM UTC-6, ooo\_saturn7 wrote:
> > > > > 
> > > > > > I have one physical server and I work only on it (no other servers).  
> > > > > > At this server I have running elastic 1.4.2 - I use this version as this is the last version elastic osgi bundle is ready for. Also at this server I have glassfish 4.1 as java-ee server.  
> > > > > > I run elastic node client inside my java-ee application. And I do it this way:  
> > > > > > Node node = nodeBuilder().local(true).clusterName("elasticsearch").node();  
> > > > > > Client client = node.client();  
> > > > > > GetResponse getResponse = client.prepareGet("my.index-0.2.2","post","1").execute().actionGet();  
> > > > > > Map\<String,Object\> source = getResponse.getSource();  
> > > > > > System.out.println("------------------------------");  
> > > > > > System.out.println("Index: "+ getResponse.getIndex());  
> > > > > > System.out.println("Type: "+ getResponse.getType());  
> > > > > > System.out.println("Id: "+ getResponse.getId());  
> > > > > > System.out.println("Version: "+ getResponse.getVersion());  
> > > > > > System.out.println(source);
> > > > > > 
> > > > > > In log I see the following:
> > > > > > 
> > > > > > > [2015-03-17T12:57:44.447+0400] [glassfish 4.1] [INFO] [org.elasticsearch.discovery] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664447] [levelValue: 800] [[[Pistol] elasticsearch/SCKIrGHQTaC5eEYmYfZ0Iw]]  
> > > > > > > [2015-03-17T12:57:44.449+0400] [glassfish 4.1] [INFO] [org.elasticsearch.cluster.service] [tid: \_ThreadID=128 \_ThreadName=elasticsearch[Pistol][clusterService#updateTask][T#1]] [timeMillis: 1426582664449] [levelValue: 800] [[[Pistol] master {new [Pistol][SCKIrGHQTaC5eEYmYfZ0Iw][[webserver1.com](http://webserver1.com) ][local[1]]{local=true}}, removed {[Pistol][uwaWFb6KTy2Sdoc8TNwdSQ][[webserver1.com](http://webserver1.com) ][local[1]]{local=true},}, reason: local-disco-initial\_connect(master)]]  
> > > > > > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.http] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] bound\_address {inet[/0:0:0:0:0:0:0:0:9202]}, publish\_address {inet[/SERVER IP:9202]}]]  
> > > > > > > [2015-03-17T12:57:44.502+0400] [glassfish 4.1] [INFO] [org.elasticsearch.node] [tid: \_ThreadID=30 \_ThreadName=http-listener-1(1)] [timeMillis: 1426582664502] [levelValue: 800] [[[Pistol] started]]  
> > > > > > > and I get this exeption: ...  
> > > > > > > Caused by: org.elasticsearch.indices.IndexMissingException:[my.index-0.2.2] missing  
> > > > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:768)  
> > > > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:691)  
> > > > > > > at org.elasticsearch.cluster.metadata.MetaData.concreteSingleIndex(MetaData.java:748)  
> > > > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:139)  
> > > > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction$AsyncSingleAction.(TransportShardSingleOperationAction.java:116)  
> > > > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:89)  
> > > > > > > at org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction.doExecute(TransportShardSingleOperationAction.java:55)  
> > > > > > > at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:75)  
> > > > > > > at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:98)  
> > > > > > > at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)  
> > > > > > > at org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)  
> > > > > > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> > > > > > > at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> > > > > > 
> > > > > > So it can't find the index - my.index-0.2.2. However this index exists! Besides, when I do curl -XGET ' [http://localhost:9200/\_cluster/state?pretty=1](http://localhost:9200/_cluster/state?pretty=1) ' I see there only one node and this is not SCKIrGHQTaC5eEYmYfZ0Iw. I suppose that the node I create using java API creates new cluster and dosn't connect to my existing cluster - that's why it says - it's master. Or I don't understand something I have problem with code. Besides I've checked tha name of cluster it's elasticsearch. So, how can I connect to my existing elasticsearch cluster?  
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9156e467-ce1d-495f-bda5-647e059e004c%40googlegroups.com) .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> > > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEqMBeCT6JjnzJbLs3XQYK882cARK1E0fWU9ZjgQATkCyQ%40mail.gmail.com) .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9vEEp6FjLMnrb1GcyDhCfFL794zwFGOvMHJG4qGCc%3DYZ769g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9vEEp6FjLMnrb1GcyDhCfFL794zwFGOvMHJG4qGCc%3DYZ769g%40mail.gmail.com) .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426615533.195965100%40f37.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426615533.195965100%40f37.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 17, 2015, 6:19pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/9 "2015-03-17T18:19:46Z")

</div>

I am newbie in elastic and I don't understand how should I work with transport client connections. Should I use singleton for Client, something like

class ElasticClientManager {  
private static Client client;

public static Client getClient(){  
if (client==null) {  
Settings settings = ImmutableSettings.settingsBuilder()  
.put("cluster.name", "elasticsearch")  
.put("client.transport.sniff", true).build();

```
   client = new TransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress("localhost",9300));
}

```

return client;  
}  
}

By other words - I create one client and keep the reference in it in singleton. Every time I need to query elastic I do

Client client = ElasticClientManager.getClient();  
GetResponse getResponse = client.prepareGet(....).execute().actionGet();

Is such approach right?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![andrew](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@andrew](https://discuss.elastic.co/u/andrew)\
**Post date:** [March 21, 2015, 8:24pm UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/10 "2015-03-21T20:24:28Z")

</div>

Hi,

You are correct that you should not create a new client for every connection, but rather re-use a single client.

Note that all the client methods support being called asynchronously by passing in a response listener, or returning a future. Which is to say, if you are submitting several queries at once, you need not wait for each to return before submitting the next.

- Andrew

> On Mar 17, 2015, at 11:19 AM, Александр Свиридов [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) wrote:
> 
> I am newbie in elastic and I don't understand how should I work with transport client connections. Should I use singleton for Client, something like
> 
> class ElasticClientManager {  
> private static Client client;
> 
> public static Client getClient(){  
> if (client==null) {  
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("cluster.name", "elasticsearch")  
> .put("client.transport.sniff", true).build();
> 
> ```
> client = new TransportClient(settings)
> .addTransportAddress(new InetSocketTransportAddress("localhost",9300));
> }
> 
> ```
> 
> return client;  
> }  
> }
> 
> By other words - I create one client and keep the reference in it in singleton. Every time I need to query elastic I do
> 
> Client client = ElasticClientManager.getClient();  
> GetResponse getResponse = client.prepareGet(....).execute().actionGet();
> 
> Is such approach right?
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru) [https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1426616386.538391541%40f217.i.mail.ru?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/D0A19724-7A49-4828-B9D1-5FD67401830E%40elastic.co](https://groups.google.com/d/msgid/elasticsearch/D0A19724-7A49-4828-B9D1-5FD67401830E%40elastic.co).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:25am UTC](https://discuss.elastic.co/t/elasticsearch-node-client-does-not-connect-to-cluster/22714/11 "2017-07-06T00:25:11Z")

</div>


