How to enable SO_KEEPALIVE with the Java HighLevel Rest client

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.

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

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 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.