# How to enable SO\_KEEPALIVE with the Java HighLevel Rest client

**URL:** <https://discuss.elastic.co/t/how-to-enable-so-keepalive-with-the-java-highlevel-rest-client/188979>\
**Category:** Elasticsearch\
**Created:** [July 4, 2019, 10:09pm UTC](https://discuss.elastic.co/t/how-to-enable-so-keepalive-with-the-java-highlevel-rest-client/188979 "2019-07-04T22:09:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![menardorama](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@menardorama](https://discuss.elastic.co/u/menardorama)\
**Post date:** [July 4, 2019, 10:09pm UTC](https://discuss.elastic.co/t/how-to-enable-so-keepalive-with-the-java-highlevel-rest-client/188979/1 "2019-07-04T22:09:15Z")

</div>

Hi,  
First of all I am not a Java developper but a Sysadmin.  
We are hosting an java microservice application that is using Elasticsearch on a Kubernetes platform.  
We are facing some « Connection Reset » on the client side due to how Kubernetes (kube-proxy in fact) manage connections.  
By design socket without SO\_KEEPALIVE are reset after 900 seconds of idle time, this can go well when there is some traffic. But things goes really bad during nights where there is no activity; the ipvs rules are closed and the connection is being reset.

Our devs are trying to figure it out but have difficulty in implementing TCP KEEPALIVE with the elastic java client (REST).

Does anybody has addressed already this issue ?

We have already lowered the tcp\_keepalive\_time above the ipvs default timeout, but the elastic java high level client doesn’t implement it by default.

Thanks a lot  
If anybody have an idea, a suggestion, a solution it would be really great.

---

<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:** [August 1, 2019, 10:09pm UTC](https://discuss.elastic.co/t/how-to-enable-so-keepalive-with-the-java-highlevel-rest-client/188979/2 "2019-08-01T22:09:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [December 14, 2020, 7:05am UTC](https://discuss.elastic.co/t/how-to-enable-so-keepalive-with-the-java-highlevel-rest-client/188979/3 "2020-12-14T07:05:02Z")

</div>

Sorry for the lack of response here @menardorama. This unanswered thread comes up near the top of the list of Google hits for this excellent question, so I'm adding a link to [https://github.com/elastic/elasticsearch/issues/65213](https://github.com/elastic/elasticsearch/issues/65213) to answer it. In a future release we will enable TCP keepalives on the Java REST client, but in the meantime that issue includes instructions for how to do it yourself.
