# Retry for java High level rest client. ES version 6.1

**URL:** <https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240>\
**Category:** Elasticsearch\
**Created:** [March 28, 2019, 5:59am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240 "2019-03-28T05:59:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikuland](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nikuland](https://discuss.elastic.co/u/nikuland)\
**Post date:** [March 28, 2019, 5:59am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/1 "2019-03-28T05:59:00Z")

</div>

we are using 6.1 ES, and Java High level Rest client. Intermittently we see "Connection reset by Peer" and "Listener timedout after 30000ms". In python there is way to set the max retries for such failures. Is there similar for Java client.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [March 29, 2019, 9:20am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/2 "2019-03-29T09:20:06Z")

</div>

See [https://github.com/elastic/elasticsearch/pull/38085](https://github.com/elastic/elasticsearch/pull/38085) , we have removed support for maxRetryTimeout in 7.0, which is what was causing listener timeouts. You can read more in the issue about it. I would suggest that you set a high maxRetryTimeout, so the listener timeouts go away and you rely on the low-level timeouts provided by the underlying http async client (socket and connect and pool timeout).

---

<div class="post-metadata">

**Author:** ![nikuland](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nikuland](https://discuss.elastic.co/u/nikuland)\
**Post date:** [April 1, 2019, 5:54am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/3 "2019-04-01T05:54:20Z")

</div>

How about failures retry, is there any such thing with high level rest client. Or we have to handle them manually

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 1, 2019, 8:28am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/4 "2019-04-01T08:28:42Z")

</div>

Yes there is, it's built-in in the low-level REST client, but it will retry a failed request (depending on the returned status code) on another node, up to all known nodes. Note that it will never retry the same request on the same node automatically.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 1, 2019, 8:43am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/5 "2019-04-01T08:43:02Z")

</div>

One thing to add is that when you hit maxRetryTimeout, if it was the first attempt to timeout, there will not be retries on another node. I would suggest to set a very high maxRetryTimeout, and reasonably low socket and connect timeout. Note that maxRetryTimeout has been removed in 7.0.

---

<div class="post-metadata">

**Author:** ![nikuland](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nikuland](https://discuss.elastic.co/u/nikuland)\
**Post date:** [April 1, 2019, 3:19pm UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/6 "2019-04-01T15:19:15Z")

</div>

so if i undertand correctly there is built in retry to low level rest client. I just need to increase the maxRetryTimeout -- right ?

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 1, 2019, 3:33pm UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/7 "2019-04-01T15:33:36Z")

</div>

yes, from the info I have, it sounds like that should help.

---

<div class="post-metadata">

**Author:** ![nikuland](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nikuland](https://discuss.elastic.co/u/nikuland)\
**Post date:** [April 1, 2019, 10:28pm UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/8 "2019-04-01T22:28:52Z")

</div>

thankyou for the response. Do you know how many retries it does by default and what is the best way to test this.

---

<div class="post-metadata">

**Author:** ![nikuland](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nikuland](https://discuss.elastic.co/u/nikuland)\
**Post date:** [April 1, 2019, 10:58pm UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/9 "2019-04-01T22:58:19Z")

</div>

Here is what i did, i added maxRetryTimeInMilllis, and then stopped ES, when i rerun the query, somehow i dont see the client retry the same failed query again. this is in single node setup. Basically i am trying out in my ownsetup. How can i test this part if there is built in retry.

---

<div class="post-metadata">

**Author:** ![Annie54](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@Annie54](https://discuss.elastic.co/u/Annie54)\
**Post date:** [April 2, 2019, 7:00am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/10 "2019-04-02T07:00:00Z")

</div>

I would suggest to set a very high maxRetryTimeout, and reasonably low socket and connect timeout. Note that maxRetryTimeout has been removed in 7.0.[diebestetest](https://www.diebestetest.de/)

---

<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:** [April 30, 2019, 7:00am UTC](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/11 "2019-04-30T07:00:01Z")

</div>

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