# How do a connect as a second client-only Node to remote cluster?

**URL:** <https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284>\
**Category:** Elasticsearch\
**Created:** [June 24, 2014, 8:29am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284 "2014-06-24T08:29:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Koen\_Smets](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/koen_smets/32/1461_2.png) [@Koen\_Smets](https://discuss.elastic.co/u/Koen_Smets)\
**Post date:** [June 24, 2014, 8:29am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/1 "2014-06-24T08:29:07Z")

</div>

Hi,

I've troubles to connect a second client-only Node via the Java API to a  
remote cluster.

The first client (configured as client-only hence no master and no data)  
runs fine on localhost:9300. However, when the second client-only node  
tries to connect to the cluster an exception gets thrown:

org.elasticsearch.cluster.block.ClusterBlockException: blocked by:  
[SERVICE\_UNAVAILABLE/1/state not recovered /  
initialized];[SERVICE\_UNAVAILABLE/2/no master];

I use the following code to connect both clients:

```
        Node node = NodeBuilder.nodeBuilder().client(true).node();
        Client client = node.client();

        GetResponse response = client.prepareGet("twitter", "tweet", 

```

"1").execute().actionGet();  
LOGGER.info(response.getSourceAsString());

```
        // on shutdown
        node.close();

```

While the second client tries to join the cluster, the logs of the first  
client show the following warnings:

o.e.d.z.p.multicast [WARN] [Odin] received ping response  
ping\_response{target  
[[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master  
[[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]],  
cluster\_name[elasticsearch]} with no matching id [1]

I assumed that the first client would be running on localhost:9300 and the  
second one would bind to localhost:9301, but doesn't do that automatically.  
Do I need to specify an additional setting to allow this scenario?

(I also tested by adding a TransportClient instead of a Node and this works  
fine)

JUnit test code and log output can be found at:

> <https://gist.github.com/ksmets/bed93778562dd2260e09>

Thx, Koen

--  
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/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 24, 2014, 10:24am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/2 "2014-06-24T10:24:41Z")

</div>

You need to set the cluster name I think.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 10:29:11, Koen Smets ([koen.smets@gmail.com](mailto:koen.smets@gmail.com)) a écrit:

Hi,

I've troubles to connect a second client-only Node via the Java API to a remote cluster.

The first client (configured as client-only hence no master and no data) runs fine on localhost:9300. However, when the second client-only node tries to connect to the cluster an exception gets thrown:

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE\_UNAVAILABLE/1/state not recovered / initialized];[SERVICE\_UNAVAILABLE/2/no master];

I use the following code to connect both clients:

```
        Node node = NodeBuilder.nodeBuilder().client(true).node();
        Client client = node.client();

        GetResponse response = client.prepareGet("twitter", "tweet", "1").execute().actionGet();
        LOGGER.info(response.getSourceAsString());

        // on shutdown
        node.close();

```

While the second client tries to join the cluster, the logs of the first client show the following warnings:

o.e.d.z.p.multicast [WARN] [Odin] received ping response ping\_response{target [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], cluster\_name[elasticsearch]} with no matching id [1]

I assumed that the first client would be running on localhost:9300 and the second one would bind to localhost:9301, but doesn't do that automatically. Do I need to specify an additional setting to allow this scenario?

(I also tested by adding a TransportClient instead of a Node and this works fine)

JUnit test code and log output can be found at: [https://gist.github.com/ksmets/bed93778562dd2260e09](https://gist.github.com/ksmets/bed93778562dd2260e09)

## Thx, Koen

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/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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/etPan.53a951e9.507ed7ab.950f%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53a951e9.507ed7ab.950f%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Koen\_Smets](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/koen_smets/32/1461_2.png) [@Koen\_Smets](https://discuss.elastic.co/u/Koen_Smets)\
**Post date:** [June 24, 2014, 10:48am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/3 "2014-06-24T10:48:43Z")

</div>

Hi David,

Setting the (default) clustername, elasticsearch, doesn't help.

grtz, Koen

On Tuesday, June 24, 2014 12:24:51 PM UTC+2, David Pilato wrote:

> You need to set the cluster name I think.
> 
> My 2 cents
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 24 juin 2014 à 10:29:11, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com) \<javascript:\>)  
> a écrit:
> 
> Hi,
> 
> I've troubles to connect a second client-only Node via the Java API to a  
> remote cluster.
> 
> The first client (configured as client-only hence no master and no data)  
> runs fine on localhost:9300. However, when the second client-only node  
> tries to connect to the cluster an exception gets thrown:
> 
> org.elasticsearch.cluster.block.ClusterBlockException: blocked by:  
> [SERVICE\_UNAVAILABLE/1/state not recovered /  
> initialized];[SERVICE\_UNAVAILABLE/2/no master];
> 
> I use the following code to connect both clients:
> 
> ```
> Node node = NodeBuilder.nodeBuilder().client(true).node();
> Client client = node.client();
> 
> GetResponse response = client.prepareGet("twitter", "tweet", 
> 
> ```
> 
> "1").execute().actionGet();  
> LOGGER.info(response.getSourceAsString());
> 
> ```
> // on shutdown
> node.close();
> 
> ```
> 
> While the second client tries to join the cluster, the logs of the first  
> client show the following warnings:
> 
> o.e.d.z.p.multicast [WARN] [Odin] received ping response  
> ping\_response{target  
> [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master  
> [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]],  
> cluster\_name[elasticsearch]} with no matching id [1]
> 
> I assumed that the first client would be running on localhost:9300 and the  
> second one would bind to localhost:9301, but doesn't do that automatically.  
> Do I need to specify an additional setting to allow this scenario?
> 
> (I also tested by adding a TransportClient instead of a Node and this  
> works fine)
> 
> JUnit test code and log output can be found at:  
> [Testing second NodeClient vs TransportClient · GitHub](https://gist.github.com/ksmets/bed93778562dd2260e09)
> 
> ## Thx, Koen
> 
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 24, 2014, 10:50am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/4 "2014-06-24T10:50:30Z")

</div>

But it sounds like your client is using another cluster name [1].  
Do you have any elasticsearch.yml in your project classpath?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 12:48:48, Koen Smets ([koen.smets@gmail.com](mailto:koen.smets@gmail.com)) a écrit:

Hi David,

Setting the (default) clustername, elasticsearch, doesn't help.

grtz, Koen

On Tuesday, June 24, 2014 12:24:51 PM UTC+2, David Pilato wrote:  
You need to set the cluster name I think.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 10:29:11, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:

Hi,

I've troubles to connect a second client-only Node via the Java API to a remote cluster.

The first client (configured as client-only hence no master and no data) runs fine on localhost:9300. However, when the second client-only node tries to connect to the cluster an exception gets thrown:

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE\_UNAVAILABLE/1/state not recovered / initialized];[SERVICE\_UNAVAILABLE/2/no master];

I use the following code to connect both clients:

```
        Node node = NodeBuilder.nodeBuilder().client(true).node();
        Client client = node.client();

        GetResponse response = client.prepareGet("twitter", "tweet", "1").execute().actionGet();
        LOGGER.info(response.getSourceAsString());

        // on shutdown
        node.close();

```

While the second client tries to join the cluster, the logs of the first client show the following warnings:

o.e.d.z.p.multicast [WARN] [Odin] received ping response ping\_response{target [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], cluster\_name[elasticsearch]} with no matching id [1]

I assumed that the first client would be running on localhost:9300 and the second one would bind to localhost:9301, but doesn't do that automatically. Do I need to specify an additional setting to allow this scenario?

(I also tested by adding a TransportClient instead of a Node and this works fine)

JUnit test code and log output can be found at: [https://gist.github.com/ksmets/bed93778562dd2260e09](https://gist.github.com/ksmets/bed93778562dd2260e09)

## Thx, Koen

## 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%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/etPan.53a957f6.216231b.950f%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53a957f6.216231b.950f%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Koen\_Smets](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/koen_smets/32/1461_2.png) [@Koen\_Smets](https://discuss.elastic.co/u/Koen_Smets)\
**Post date:** [June 24, 2014, 11:32am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/5 "2014-06-24T11:32:12Z")

</div>

It's not the clustername. The unit test works if I force the node to use  
another port...

```
        Settings settings = 

```

ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch")  
.put("network.publish\_host",  
"192.168.2.15").put("network.bind\_host", "192.168.2.15")  
.put("transport.tcp.port",  
9301).put("transport.publish\_port", 9301).build();

But by default transport.tcp.port is range 9300-9400, but it always picks  
both for the first and the second client always 9300.

Shouldn't the port clash be discovered automatically?

grtz, Koen

On Tuesday, June 24, 2014 12:50:41 PM UTC+2, David Pilato wrote:

> But it sounds like your client is using another cluster name [1].  
> Do you have any elasticsearch.yml in your project classpath?
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 24 juin 2014 à 12:48:48, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com) \<javascript:\>)  
> a écrit:
> 
> Hi David,
> 
> Setting the (default) clustername, elasticsearch, doesn't help.
> 
> grtz, Koen
> 
> On Tuesday, June 24, 2014 12:24:51 PM UTC+2, David Pilato wrote:
> 
> > You need to set the cluster name I think.
> > 
> > My 2 cents
> > 
> > ```
> > -- 
> > 
> > ```
> > 
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> > [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > 
> > Le 24 juin 2014 à 10:29:11, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:
> > 
> > Hi,
> > 
> > I've troubles to connect a second client-only Node via the Java API to a  
> > remote cluster.
> > 
> > The first client (configured as client-only hence no master and no data)  
> > runs fine on localhost:9300. However, when the second client-only node  
> > tries to connect to the cluster an exception gets thrown:
> > 
> > org.elasticsearch.cluster.block.ClusterBlockException: blocked by:  
> > [SERVICE\_UNAVAILABLE/1/state not recovered /  
> > initialized];[SERVICE\_UNAVAILABLE/2/no master];
> > 
> > I use the following code to connect both clients:
> > 
> > ```
> > Node node = NodeBuilder.nodeBuilder().client(true).node();
> > Client client = node.client();
> > 
> > GetResponse response = client.prepareGet("twitter", "tweet", 
> > 
> > ```
> > 
> > "1").execute().actionGet();  
> > LOGGER.info(response.getSourceAsString());
> > 
> > ```
> > // on shutdown
> > node.close();
> > 
> > ```
> > 
> > While the second client tries to join the cluster, the logs of the first  
> > client show the following warnings:
> > 
> > o.e.d.z.p.multicast [WARN] [Odin] received ping response  
> > ping\_response{target  
> > [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master  
> > [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]],  
> > cluster\_name[elasticsearch]} with no matching id [1]
> > 
> > I assumed that the first client would be running on localhost:9300 and  
> > the second one would bind to localhost:9301, but doesn't do that  
> > automatically. Do I need to specify an additional setting to allow this  
> > scenario?
> > 
> > (I also tested by adding a TransportClient instead of a Node and this  
> > works fine)
> > 
> > JUnit test code and log output can be found at:  
> > [Testing second NodeClient vs TransportClient · GitHub](https://gist.github.com/ksmets/bed93778562dd2260e09)
> > 
> > ## Thx, Koen
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%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/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [June 24, 2014, 12:34pm UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/6 "2014-06-24T12:34:49Z")

</div>

I see. Indeed. As soon as we are able to ping a cluster on a port, I think we don't try to increase port number and try all ports within the same IP address.  
If you need to set a specific address/port, you should disable multicast on your client Node and provide a unicast list of nodes (with the right port to use).

Does it make sense?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 13:32:17, Koen Smets ([koen.smets@gmail.com](mailto:koen.smets@gmail.com)) a écrit:

It's not the clustername. The unit test works if I force the node to use another port...

```
        Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch")
                .put("network.publish_host", "192.168.2.15").put("network.bind_host", "192.168.2.15")
                .put("transport.tcp.port", 9301).put("transport.publish_port", 9301).build();

```

But by default transport.tcp.port is range 9300-9400, but it always picks both for the first and the second client always 9300.

Shouldn't the port clash be discovered automatically?

grtz, Koen

On Tuesday, June 24, 2014 12:50:41 PM UTC+2, David Pilato wrote:  
But it sounds like your client is using another cluster name [1].  
Do you have any elasticsearch.yml in your project classpath?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 12:48:48, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:

Hi David,

Setting the (default) clustername, elasticsearch, doesn't help.

grtz, Koen

On Tuesday, June 24, 2014 12:24:51 PM UTC+2, David Pilato wrote:  
You need to set the cluster name I think.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 24 juin 2014 à 10:29:11, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:

Hi,

I've troubles to connect a second client-only Node via the Java API to a remote cluster.

The first client (configured as client-only hence no master and no data) runs fine on localhost:9300. However, when the second client-only node tries to connect to the cluster an exception gets thrown:

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE\_UNAVAILABLE/1/state not recovered / initialized];[SERVICE\_UNAVAILABLE/2/no master];

I use the following code to connect both clients:

```
        Node node = NodeBuilder.nodeBuilder().client(true).node();
        Client client = node.client();

        GetResponse response = client.prepareGet("twitter", "tweet", "1").execute().actionGet();
        LOGGER.info(response.getSourceAsString());

        // on shutdown
        node.close();

```

While the second client tries to join the cluster, the logs of the first client show the following warnings:

o.e.d.z.p.multicast [WARN] [Odin] received ping response ping\_response{target [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], cluster\_name[elasticsearch]} with no matching id [1]

I assumed that the first client would be running on localhost:9300 and the second one would bind to localhost:9301, but doesn't do that automatically. Do I need to specify an additional setting to allow this scenario?

(I also tested by adding a TransportClient instead of a Node and this works fine)

JUnit test code and log output can be found at: [https://gist.github.com/ksmets/bed93778562dd2260e09](https://gist.github.com/ksmets/bed93778562dd2260e09)

## Thx, Koen

## 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%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/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%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/etPan.53a97069.7fdcc233.950f%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53a97069.7fdcc233.950f%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Koen\_Smets](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/koen_smets/32/1461_2.png) [@Koen\_Smets](https://discuss.elastic.co/u/Koen_Smets)\
**Post date:** [June 24, 2014, 1:57pm UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/7 "2014-06-24T13:57:11Z")

</div>

Thx David for the clarification, it makes sense. I (wrongfully) assumed  
that the second client would connect to 9301; similarly to my logstash  
instance that also connects to port 3901, when running on the same server  
as the elasticsearch instance.

Since I don't need Node functionality anyway, I'll stick to using  
TransportClients.

grtz, Koen

On Tuesday, June 24, 2014 2:35:25 PM UTC+2, David Pilato wrote:

> I see. Indeed. As soon as we are able to ping a cluster on a port, I think  
> we don't try to increase port number and try all ports within the same IP  
> address.  
> If you need to set a specific address/port, you should disable multicast  
> on your client Node and provide a unicast list of nodes (with the right  
> port to use).
> 
> Does it make sense?
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 24 juin 2014 à 13:32:17, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com) \<javascript:\>)  
> a écrit:
> 
> It's not the clustername. The unit test works if I force the node to use  
> another port...
> 
> ```
> Settings settings = ImmutableSettings.settingsBuilder().put("
> 
> ```
> 
> cluster.name", "elasticsearch")  
> .put("network.publish\_host",  
> "192.168.2.15").put("network.bind\_host", "192.168.2.15")  
> .put("transport.tcp.port",  
> 9301).put("transport.publish\_port", 9301).build();
> 
> But by default transport.tcp.port is range 9300-9400, but it always picks  
> both for the first and the second client always 9300.
> 
> Shouldn't the port clash be discovered automatically?
> 
> grtz, Koen
> 
> On Tuesday, June 24, 2014 12:50:41 PM UTC+2, David Pilato wrote:
> 
> > But it sounds like your client is using another cluster name [1].  
> > Do you have any elasticsearch.yml in your project classpath?
> > 
> > ```
> > -- 
> > 
> > ```
> > 
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> > [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > 
> > Le 24 juin 2014 à 12:48:48, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:
> > 
> > Hi David,
> > 
> > Setting the (default) clustername, elasticsearch, doesn't help.
> > 
> > grtz, Koen
> > 
> > On Tuesday, June 24, 2014 12:24:51 PM UTC+2, David Pilato wrote:
> > 
> > > You need to set the cluster name I think.
> > > 
> > > My 2 cents
> > > 
> > > ```
> > > -- 
> > > 
> > > ```
> > > 
> > > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> > > [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > > 
> > > Le 24 juin 2014 à 10:29:11, Koen Smets ([koen....@gmail.com](mailto:koen....@gmail.com)) a écrit:
> > > 
> > > Hi,
> > > 
> > > I've troubles to connect a second client-only Node via the Java API to a  
> > > remote cluster.
> > > 
> > > The first client (configured as client-only hence no master and no data)  
> > > runs fine on localhost:9300. However, when the second client-only node  
> > > tries to connect to the cluster an exception gets thrown:
> > > 
> > > org.elasticsearch.cluster.block.ClusterBlockException: blocked by:  
> > > [SERVICE\_UNAVAILABLE/1/state not recovered /  
> > > initialized];[SERVICE\_UNAVAILABLE/2/no master];
> > > 
> > > I use the following code to connect both clients:
> > > 
> > > ```
> > > Node node = NodeBuilder.nodeBuilder().client(true).node();
> > > Client client = node.client();
> > > 
> > > GetResponse response = client.prepareGet("twitter", "tweet", 
> > > 
> > > ```
> > > 
> > > "1").execute().actionGet();  
> > > LOGGER.info(response.getSourceAsString());
> > > 
> > > ```
> > > // on shutdown
> > > node.close();
> > > 
> > > ```
> > > 
> > > While the second client tries to join the cluster, the logs of the first  
> > > client show the following warnings:
> > > 
> > > o.e.d.z.p.multicast [WARN] [Odin] received ping response  
> > > ping\_response{target  
> > > [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]], master  
> > > [[Firebolt][DqdgEEe8RwSyVDUuqmQw4w][p2][inet[/192.168.2.21:9300]]],  
> > > cluster\_name[elasticsearch]} with no matching id [1]
> > > 
> > > I assumed that the first client would be running on localhost:9300 and  
> > > the second one would bind to localhost:9301, but doesn't do that  
> > > automatically. Do I need to specify an additional setting to allow this  
> > > scenario?
> > > 
> > > (I also tested by adding a TransportClient instead of a Node and this  
> > > works fine)
> > > 
> > > JUnit test code and log output can be found at:  
> > > [Testing second NodeClient vs TransportClient · GitHub](https://gist.github.com/ksmets/bed93778562dd2260e09)
> > > 
> > > ## Thx, Koen
> > > 
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/868dc883-dd39-44ac-ab56-1ac609f1f63f%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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/43ed69ab-83e8-4128-8450-bcb94fc93852%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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ac506781-daf9-4255-ac4c-09ac1b833d4a%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/a3a05428-c8a5-4d69-9f3b-49f3808c1768%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a3a05428-c8a5-4d69-9f3b-49f3808c1768%40googlegroups.com).  
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, 1:20am UTC](https://discuss.elastic.co/t/how-do-a-connect-as-a-second-client-only-node-to-remote-cluster/18284/8 "2017-07-06T01:20:08Z")

</div>


