# Connecting remotely to elastic search cluster

**URL:** <https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478>\
**Category:** Elasticsearch\
**Created:** [January 5, 2015, 12:46pm UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478 "2015-01-05T12:46:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_Tiwary](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vijay\_Tiwary](https://discuss.elastic.co/u/Vijay_Tiwary)\
**Post date:** [January 5, 2015, 12:46pm UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478/1 "2015-01-05T12:46:15Z")

</div>

I am trying to connect remotely to elastic search cluster having 2 nodes  
My question is I am able to query successfully only when we configure both  
the cluster name and host name of the individual nodes? Why it doesn't work  
if I only configure the cluster name in my client code

Settings settings = ImmutableSettings.settingsBuilder()  
.put("cluster.name", "myClusterName").build();

Client client = new TransportClient(settings ).addTransportAddress(new InetSocketTransportAddress("host1", 9300))

```
    .addTransportAddress(new InetSocketTransportAddress("host2", 9300));

```

--  
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/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%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:** [January 5, 2015, 2:47pm UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478/2 "2015-01-05T14:47:23Z")

</div>

If you don’t want to define transport addresses, you’d better use a NodeClient.  
A NodeClient is actually a node running inside the cluster (with auto discovery…) but without any data.

You just need to provide the cluster name with a NodeClient. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client) [http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client)

--  
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) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 5 janv. 2015 à 13:46, Vijay Tiwary [vijaykr.tiwary@gmail.com](mailto:vijaykr.tiwary@gmail.com) a écrit :
> 
> I am trying to connect remotely to Elasticsearch cluster having 2 nodes  
> My question is I am able to query successfully only when we configure both the cluster name and host name of the individual nodes? Why it doesn't work if I only configure the cluster name in my client code
> 
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("cluster.name", "myClusterName").build();  
> Client client = new TransportClient(settings ).addTransportAddress(new InetSocketTransportAddress("host1", 9300))  
> .addTransportAddress(new InetSocketTransportAddress("host2", 9300));
> 
> --  
> 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/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com?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/36D10C69-1F87-498C-A934-094D3C3B6516%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/36D10C69-1F87-498C-A934-094D3C3B6516%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vijay\_Tiwary](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vijay\_Tiwary](https://discuss.elastic.co/u/Vijay_Tiwary)\
**Post date:** [January 5, 2015, 6:15pm UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478/3 "2015-01-05T18:15:47Z")

</div>

Thanks David once again. Can you please help in deciding which one should I  
go for NodeClient or TransportClient for production deployments.  
From the Elasticsearch documentation what I understand is that Node client  
eliminates the double hop that is present in Transport Client. Shall I opt  
for Node client then? Please suggest.

On Monday, January 5, 2015 8:17:40 PM UTC+5:30, David Pilato wrote:

> If you don’t want to define transport addresses, you’d better use a  
> NodeClient.  
> A NodeClient is actually a node running inside the cluster (with auto  
> discovery…) but without any data.
> 
> You just need to provide the cluster name with a NodeClient. See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client)
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)  
> [http://Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs  
> [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 5 janv. 2015 à 13:46, Vijay Tiwary \<[vijaykr...@gmail.com](mailto:vijaykr...@gmail.com) \<javascript:\>\>  
> a écrit :
> 
> I am trying to connect remotely to Elasticsearch cluster having 2 nodes  
> My question is I am able to query successfully only when we configure both  
> the cluster name and host name of the individual nodes? Why it doesn't work  
> if I only configure the cluster name in my client code
> 
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("cluster.name", "myClusterName").build();
> 
> Client client = new TransportClient(settings ).addTransportAddress(new InetSocketTransportAddress("host1", 9300))
> 
> ```
> .addTransportAddress(new InetSocketTransportAddress("host2", 9300));
> 
> ```
> 
> --  
> 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/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%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/98810b45-e4b5-4776-ac45-ba6b41adeff9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/98810b45-e4b5-4776-ac45-ba6b41adeff9%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:** [January 5, 2015, 7:51pm UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478/4 "2015-01-05T19:51:37Z")

</div>

I myself prefer TransportClient as it has absolutely no impact on the cluster state.  
A new node joining the cluster generates a cluster state update which is propagated to all nodes.

I prefer having a very stable cluster state than continuous updates. Think about a Java batch which starts every minute and connect to the cluster to perform whatever action.  
That would be a lot of events per day.

That’s why I mostly prefer using TransportClient.

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) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 5 janv. 2015 à 19:15, Vijay Tiwary [vijaykr.tiwary@gmail.com](mailto:vijaykr.tiwary@gmail.com) a écrit :
> 
> Thanks David once again. Can you please help in deciding which one should I go for NodeClient or TransportClient for production deployments.  
> From the Elasticsearch documentation what I understand is that Node client eliminates the double hop that is present in Transport Client. Shall I opt for Node client then? Please suggest.
> 
> On Monday, January 5, 2015 8:17:40 PM UTC+5:30, David Pilato wrote:  
> If you don’t want to define transport addresses, you’d better use a NodeClient.  
> A NodeClient is actually a node running inside the cluster (with auto discovery…) but without any data.
> 
> You just need to provide the cluster name with a NodeClient. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client) [http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client)
> 
> --  
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com) [http://elasticsearch.com/](http://elasticsearch.com/)  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> > Le 5 janv. 2015 à 13:46, Vijay Tiwary \<[vijaykr...@gmail.com](mailto:vijaykr...@gmail.com) \<javascript:\>\> a écrit :
> > 
> > I am trying to connect remotely to Elasticsearch cluster having 2 nodes  
> > My question is I am able to query successfully only when we configure both the cluster name and host name of the individual nodes? Why it doesn't work if I only configure the cluster name in my client code
> > 
> > Settings settings = ImmutableSettings.settingsBuilder()  
> > .put("cluster.name [http://cluster.name/](http://cluster.name/)", "myClusterName").build();  
> > Client client = new TransportClient(settings ).addTransportAddress(new InetSocketTransportAddress("host1", 9300))  
> > .addTransportAddress(new InetSocketTransportAddress("host2", 9300));
> > 
> > --  
> > 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/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/dd201d66-71b4-4d74-bb99-255144a083a2%40googlegroups.com?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) [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/98810b45-e4b5-4776-ac45-ba6b41adeff9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/98810b45-e4b5-4776-ac45-ba6b41adeff9%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/98810b45-e4b5-4776-ac45-ba6b41adeff9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/98810b45-e4b5-4776-ac45-ba6b41adeff9%40googlegroups.com?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/9740D8FF-F93A-4C5B-92E9-15602E1701FF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/9740D8FF-F93A-4C5B-92E9-15602E1701FF%40pilato.fr).  
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:40am UTC](https://discuss.elastic.co/t/connecting-remotely-to-elastic-search-cluster/21478/5 "2017-07-06T00:40:46Z")

</div>


