# Java client handling connection failure

**URL:** <https://discuss.elastic.co/t/java-client-handling-connection-failure/16965>\
**Category:** Elasticsearch\
**Created:** [April 11, 2014, 7:13pm UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965 "2014-04-11T19:13:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [April 11, 2014, 7:13pm UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965/1 "2014-04-11T19:13:35Z")

</div>

I am currently creating a client connection as shown below. One of the  
questions I have is what is the right way to provide high availability and  
reseliency on the client side when the node that I am connecting to fails?  
Does this client automatically discovers all the nodes in the cluster and  
retry on other nodes?

Client client = new TransportClient()

.addTransportAddress(new InetSocketTransportAddress("host1", 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/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [April 12, 2014, 12:52pm UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965/2 "2014-04-12T12:52:10Z")

</div>

Hello Mohit ,

I am no expert in this , but i feel adding the sniff might help -

Settings settings = ImmutableSettings.settingsBuilder()  
.put("cluster.name", clusterName)

- .put("client.transport.sniff", true)\*  
.build();  
TransportClient client = new TransportClient(settings);  
client.addTransportAddresses(new InetSocketTransportAddress(esHost,  
esPort));

Thanks  
Vineeth

On Sat, Apr 12, 2014 at 12:43 AM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> I am currently creating a client connection as shown below. One of the  
> questions I have is what is the right way to provide high availability and  
> reseliency on the client side when the node that I am connecting to fails?  
> Does this client automatically discovers all the nodes in the cluster and  
> retry on other nodes?
> 
> Client client = new TransportClient()
> 
> .addTransportAddress(new InetSocketTransportAddress("host1", 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/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%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/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [April 12, 2014, 4:24pm UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965/3 "2014-04-12T16:24:39Z")

</div>

Yeah I looked at it but it only says that it's used as round robin. It  
doesn't talk about reseliency during connection faiiures

On Sat, Apr 12, 2014 at 5:52 AM, vineeth mohan [vm.vineethmohan@gmail.com](mailto:vm.vineethmohan@gmail.com)wrote:

> Hello Mohit ,
> 
> I am no expert in this , but i feel adding the sniff might help -
> 
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("cluster.name", clusterName)
> 
> - .put("client.transport.sniff", true)\*  
> .build();  
> TransportClient client = new TransportClient(settings);  
> client.addTransportAddresses(new InetSocketTransportAddress(esHost,  
> esPort));
> 
> Thanks  
> Vineeth
> 
> On Sat, Apr 12, 2014 at 12:43 AM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> 
> > I am currently creating a client connection as shown below. One of the  
> > questions I have is what is the right way to provide high availability and  
> > reseliency on the client side when the node that I am connecting to fails?  
> > Does this client automatically discovers all the nodes in the cluster and  
> > retry on other nodes?
> > 
> > Client client = new TransportClient()
> > 
> > .addTransportAddress(new InetSocketTransportAddress("host1", 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/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%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/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%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/CAOT3TWpnvO\_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWpnvO_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 13, 2014, 9:48am UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965/4 "2014-04-13T09:48:19Z")

</div>

The TransportClient uses a heartbeat signal every 5 secs to discover if the  
node can still respond. If not, it will be dropped. "Sniffing" means, the  
TransportClient can automatically connect to newly discovered nodes (e.g.  
if the node comes up again, the client reconnects). The TransportClient  
must be connected to at least one node all the time.

Jörg

On Sat, Apr 12, 2014 at 6:24 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> Yeah I looked at it but it only says that it's used as round robin. It  
> doesn't talk about reseliency during connection faiiures
> 
> On Sat, Apr 12, 2014 at 5:52 AM, vineeth mohan [vm.vineethmohan@gmail.com](mailto:vm.vineethmohan@gmail.com)wrote:
> 
> > Hello Mohit ,
> > 
> > I am no expert in this , but i feel adding the sniff might help -
> > 
> > Settings settings = ImmutableSettings.settingsBuilder()  
> > .put("cluster.name", clusterName)
> > 
> > - .put("client.transport.sniff", true)\*  
> > .build();  
> > TransportClient client = new TransportClient(settings);  
> > client.addTransportAddresses(new InetSocketTransportAddress(esHost,  
> > esPort));
> > 
> > Thanks  
> > Vineeth
> > 
> > On Sat, Apr 12, 2014 at 12:43 AM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> > 
> > > I am currently creating a client connection as shown below. One of the  
> > > questions I have is what is the right way to provide high availability and  
> > > reseliency on the client side when the node that I am connecting to fails?  
> > > Does this client automatically discovers all the nodes in the cluster and  
> > > retry on other nodes?
> > > 
> > > Client client = new TransportClient()
> > > 
> > > .addTransportAddress(new InetSocketTransportAddress("host1", 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/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoNGePYwohTZwSc1EBgjkUZ3zvd4NLcLdiYUX8eUUnj1g%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/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nm1s38eqazRbLHBfwO3xZaLt9SmRWLKkGRCvBV3MPqig%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/CAOT3TWpnvO\_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWpnvO_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWpnvO\_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWpnvO_npcnb%2B3H2FY46wamc7iYOf2DkTq7sy4yTNBkDwg%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/CAKdsXoFJ02KNZWuzAqck%2B5zgc6JeE6EVvRCTtDBhguQAV%2B%3D7zw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFJ02KNZWuzAqck%2B5zgc6JeE6EVvRCTtDBhguQAV%2B%3D7zw%40mail.gmail.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:36am UTC](https://discuss.elastic.co/t/java-client-handling-connection-failure/16965/5 "2017-07-06T01:36:10Z")

</div>


