# Can't get the java client to connect to the ES server when both are on my computer

**URL:** <https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490>\
**Category:** Elasticsearch\
**Created:** [January 25, 2012, 8:06am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490 "2012-01-25T08:06:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 25, 2012, 8:06am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/1 "2012-01-25T08:06:00Z")

</div>

Hi,  
I've started working with ES in order to implement search capabilities in  
my company's web-application.  
I have a problem connecting a client node (via the java api) to the only  
data node I'm running; They're both running locally on my computer (Win 7).  
I had several issues with "Failed to create a selector" and "Unable to  
establish loopback connection" exceptions on the server but they were  
solved (or just postponed not sure) by disabling all firewalls (commercial  
and windows) and by setting the "network.host" property in the  
elasticsearch.yml config file of the data-node to the ip of the computer.  
The problem I continued on to was not beeing able to connect from my  
client-node to the other node, I thought the problem was with the fact I  
did not configure a cluster.name property and so I set it in both the  
elasticsearch.yml of the data-node and in the "settings map" of the  
client-node.  
Upon startup I get the following log warning: "waited for 30s and no  
initial state was set by the discovery" and it continues but when I try to  
perform an index operation I get a MasterNotDiscoveredException.  
I've gisted the log of the data-node [https://gist.github.com/1675252](https://gist.github.com/1675252) and  
the way I'm instantiating the client-node. [https://gist.github.com/1675266](https://gist.github.com/1675266)  
I'm really not sure why this is so hard...  
Would appreciate any help pushing forward,  
Ittai

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 25, 2012, 8:30am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/2 "2012-01-25T08:30:20Z")

</div>

What is the full code you use to create the transport client?

Peter.

On 25 Jan., 09:06, Ittai Zeidman [it...@fashion-traffic.com](mailto:it...@fashion-traffic.com) wrote:

> Hi,  
> I've started working with ES in order to implement search capabilities in  
> my company's web-application.  
> I have a problem connecting a client node (via the java api) to the only  
> data node I'm running; They're both running locally on my computer (Win 7).  
> I had several issues with "Failed to create a selector" and "Unable to  
> establish loopback connection" exceptions on the server but they were  
> solved (or just postponed not sure) by disabling all firewalls (commercial  
> and windows) and by setting the "network.host" property in the  
> elasticsearch.yml config file of the data-node to the ip of the computer.  
> The problem I continued on to was not beeing able to connect from my  
> client-node to the other node, I thought the problem was with the fact I  
> did not configure a cluster.name property and so I set it in both the  
> elasticsearch.yml of the data-node and in the "settings map" of the  
> client-node.  
> Upon startup I get the following log warning: "waited for 30s and no  
> initial state was set by the discovery" and it continues but when I try to  
> perform an index operation I get a MasterNotDiscoveredException.  
> I've gisted the log of the data-node [https://gist.github.com/1675252](https://gist.github.com/1675252) and  
> the way I'm instantiating the client-node. [https://gist.github.com/1675266](https://gist.github.com/1675266)  
> I'm really not sure why this is so hard...  
> Would appreciate any help pushing forward,  
> Ittai

---

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 25, 2012, 8:36am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/3 "2012-01-25T08:36:11Z")

</div>

Map\<String,String\> settings = new HashMap\<String,String\>();  
settings.put("node.client","true");  
settings.put("cluster.name","mycluster");  
final NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();  
nodeBuilder.getSettings().put(settings);  
node = nodeBuilder.node();

It's a client-node and not a transport client.  
It's also as a gist [https://gist.github.com/1675266](https://gist.github.com/1675266)

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 25, 2012, 2:37pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/4 "2012-01-25T14:37:49Z")

</div>

I think you either need the transport client or you need to start the  
node and get the client from that + use data=false

[http://groups.google.com/group/elasticsearch/browse\_thread/thread/4082ea186bbb9c30](http://groups.google.com/group/elasticsearch/browse_thread/thread/4082ea186bbb9c30)

Peter.

On 25 Jan., 09:36, Ittai Zeidman [it...@fashion-traffic.com](mailto:it...@fashion-traffic.com) wrote:

> Map\<String,String\> settings = new HashMap\<String,String\>();  
> settings.put("node.client","true");  
> settings.put("cluster.name","mycluster");  
> final NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();  
> nodeBuilder.getSettings().put(settings);  
> node = nodeBuilder.node();
> 
> It's a client-node and not a transport client.  
> It's also as a gist [https://gist.github.com/1675266](https://gist.github.com/1675266)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 25, 2012, 4:47pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/5 "2012-01-25T16:47:43Z")

</div>

Probably multicast still does not work on your end. You can set org.elastcisearch.discovery to TRACE to see a bit more whats going on.

On Wednesday, January 25, 2012 at 4:37 PM, Karussell wrote:

> I think you either need the transport client or you need to start the  
> node and get the client from that + use data=false
> 
> [http://groups.google.com/group/elasticsearch/browse\_thread/thread/4082ea186bbb9c30](http://groups.google.com/group/elasticsearch/browse_thread/thread/4082ea186bbb9c30)
> 
> Peter.
> 
> On 25 Jan., 09:36, Ittai Zeidman \<[it...@fashion-traffic.com](mailto:it...@fashion-traffic.com) ([http://fashion-traffic.com](http://fashion-traffic.com))\> wrote:
> 
> > Map\<String,String\> settings = new HashMap\<String,String\>();  
> > settings.put("node.client","true");  
> > settings.put("cluster.name ([http://cluster.name](http://cluster.name))","mycluster");  
> > final NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder();  
> > nodeBuilder.getSettings().put(settings);  
> > node = nodeBuilder.node();
> > 
> > It's a client-node and not a transport client.  
> > It's also as a gist [https://gist.github.com/1675266](https://gist.github.com/1675266)

---

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 25, 2012, 7:38pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/6 "2012-01-25T19:38:21Z")

</div>

Hi Shay and Peter,  
What actually solved the issue was just changing the above settings from  
"node.client"/"true" to "node.data"/"false" which seems very strange to me  
as in the elasticsearch site it says they're complimentary, right?  
In any case I've verified that by swapping one with the other I'm no longer  
hitting that wall (but others unfortunately).  
If you still think I'm doing something wrong I'd be happy to hear.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 25, 2012, 9:49pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/7 "2012-01-25T21:49:37Z")

</div>

One you changed it from a node client, then it will act as a data node (the default, btw), which means it might possibly form its own cluster of a single node if it can't connect to other nodes.

On Wednesday, January 25, 2012 at 9:38 PM, Ittai Zeidman wrote:

> Hi Shay and Peter,  
> What actually solved the issue was just changing the above settings from "node.client"/"true" to "node.data"/"false" which seems very strange to me as in the elasticsearch site it says they're complimentary, right?  
> In any case I've verified that by swapping one with the other I'm no longer hitting that wall (but others unfortunately).  
> If you still think I'm doing something wrong I'd be happy to hear.

---

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 25, 2012, 10:02pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/8 "2012-01-25T22:02:04Z")

</div>

Oh ok,  
I see what you're saying.  
I'll try to use the transport client and put the discovery log on trace and report back.  
Can you give me some hints on what can cause problems with multicast?  
I've disabled the firewalls.  
Thanks!

ב-25 בינו 2012, בשעה 23:49, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) כתב/ה:

> One you changed it from a node client, then it will act as a data node (the default, btw), which means it might possibly form its own cluster of a single node if it can't connect to other nodes.  
> On Wednesday, January 25, 2012 at 9:38 PM, Ittai Zeidman wrote:
> 
> > Hi Shay and Peter,  
> > What actually solved the issue was just changing the above settings from "node.client"/"true" to "node.data"/"false" which seems very strange to me as in the elasticsearch site it says they're complimentary, right?  
> > In any case I've verified that by swapping one with the other I'm no longer hitting that wall (but others unfortunately).  
> > If you still think I'm doing something wrong I'd be happy to hear.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 25, 2012, 10:14pm UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/9 "2012-01-25T22:14:58Z")

</div>

I am not sure what causes the problems with multicast…, if you set the discovery to TRACE logging and gist it, maybe it will give a hint. The TransportClient simply connects directly to the server (you explicitly add the address).

On Thursday, January 26, 2012 at 12:02 AM, Ittai Zeidman wrote:

> Oh ok,  
> I see what you're saying.  
> I'll try to use the transport client and put the discovery log on trace and report back.  
> Can you give me some hints on what can cause problems with multicast?  
> I've disabled the firewalls.  
> Thanks!
> 
> ב-25 בינו 2012, בשעה 23:49, Shay Banon \<[kimchy@gmail.com](mailto:kimchy@gmail.com) ([mailto:kimchy@gmail.com](mailto:kimchy@gmail.com))\> כתב/ה:
> 
> > One you changed it from a node client, then it will act as a data node (the default, btw), which means it might possibly form its own cluster of a single node if it can't connect to other nodes.
> > 
> > On Wednesday, January 25, 2012 at 9:38 PM, Ittai Zeidman wrote:
> > 
> > > Hi Shay and Peter,  
> > > What actually solved the issue was just changing the above settings from "node.client"/"true" to "node.data"/"false" which seems very strange to me as in the elasticsearch site it says they're complimentary, right?  
> > > In any case I've verified that by swapping one with the other I'm no longer hitting that wall (but others unfortunately).  
> > > If you still think I'm doing something wrong I'd be happy to hear.

---

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 26, 2012, 8:14am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/10 "2012-01-26T08:14:16Z")

</div>

Hi Shay,  
I was indeed able to connect (and pass the test I mentioned in the other  
question) by switching to a TransportClient.  
I've gisted [https://gist.github.com/1681639](https://gist.github.com/1681639) the log of the client (when  
using node.client(true)) and setting the Discovery to TRACE as you  
suggested.  
I did not see anything there but of course that unfortunately doesn't  
guarantee anything.  
I'd really rather use the client node (as to avoid the double hop) and so I  
appreciate the help with trying to solve the multicast issue.  
If there is anyhthing additional you'd like me to try please say so.

Thanks again,  
Ittai

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 26, 2012, 9:53am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/11 "2012-01-26T09:53:48Z")

</div>

Still not sure why multicast does not work, if you bind on localhost, try maybe 127.0.0.1. You can still use the node client, just configure it with unicast discovery. In the settings when you initialize the node, set: discovery.zen.ping.unicast.hosts to "host1,host2,…".

On Thursday, January 26, 2012 at 10:14 AM, Ittai Zeidman wrote:

> Hi Shay,  
> I was indeed able to connect (and pass the test I mentioned in the other question) by switching to a TransportClient.  
> I've gisted ([Java API Client TRACE discovery log · GitHub](https://gist.github.com/1681639)) the log of the client (when using node.client(true)) and setting the Discovery to TRACE as you suggested.  
> I did not see anything there but of course that unfortunately doesn't guarantee anything.  
> I'd really rather use the client node (as to avoid the double hop) and so I appreciate the help with trying to solve the multicast issue.  
> If there is anyhthing additional you'd like me to try please say so.
> 
> Thanks again,  
> Ittai

---

<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, 3:41am UTC](https://discuss.elastic.co/t/cant-get-the-java-client-to-connect-to-the-es-server-when-both-are-on-my-computer/6490/12 "2017-07-06T03:41:23Z")

</div>


