# ES Rest High Level Client throws SocketTimeoutException after being idle for sometime

**URL:** <https://discuss.elastic.co/t/es-rest-high-level-client-throws-sockettimeoutexception-after-being-idle-for-sometime/188188>\
**Category:** Elasticsearch\
**Created:** [June 30, 2019, 11:29am UTC](https://discuss.elastic.co/t/es-rest-high-level-client-throws-sockettimeoutexception-after-being-idle-for-sometime/188188 "2019-06-30T11:29:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![0b3d953a632983bedb48](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/0b3d953a632983bedb48/32/37499_2.png) [@0b3d953a632983bedb48](https://discuss.elastic.co/u/0b3d953a632983bedb48)\
**Post date:** [June 30, 2019, 11:29am UTC](https://discuss.elastic.co/t/es-rest-high-level-client-throws-sockettimeoutexception-after-being-idle-for-sometime/188188/1 "2019-06-30T11:29:28Z")

</div>

`RestHighLevelClient` is used to connect to ES 6.4(hosted on AWS) in a spring-boot app. When the app goes idle for some time, and request arrives, then the `RestHighLevelClient` throws `SocketTimeoutException`:

```
[Request processing failed; nested exception is org.springframework.data.elasticsearch.ElasticsearchException: Error while bulk for request: org.elasticsearch.action.bulk.BulkRequest@21511b6c] w
java.net.SocketTimeoutException: 5,000 milliseconds timeout on connection http-outgoing-38 [ACTIVE]
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.timeout(HttpAsyncRequestExecutor.java:387) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:92) ~[httpasyncclient-4.1.4.jar!/:4.1.4]
at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:39) ~[httpasyncclient-4.1.4.jar!/:4.1.4]
at org.apache.http.impl.nio.reactor.AbstractIODispatch.timeout(AbstractIODispatch.java:175) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionTimedOut(BaseIOReactor.java:263) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.AbstractIOReactor.timeoutCheck(AbstractIOReactor.java:492) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:213) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591) ~[httpcore-nio-4.4.11.jar!/:4.4.11]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

```

_RestHighLevelClient_ is created using:

```
@Bean
  RestHighLevelClient client() {

        ClientConfiguration clientConfiguration = ClientConfiguration.builder()
                .connectedTo(elasticsearchHostAndPort)
                .build();

        return RestClients.create(clientConfiguration).rest();
   }

```

increasing timeout does not help.

Any hints/workarounds?

---

<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:** [July 1, 2019, 11:25am UTC](https://discuss.elastic.co/t/es-rest-high-level-client-throws-sockettimeoutexception-after-being-idle-for-sometime/188188/2 "2019-07-01T11:25:17Z")

</div>

May be you should give a try to the [Sniffer](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/sniffer.html)?

---

<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 15, 2019, 3:41pm UTC](https://discuss.elastic.co/t/es-rest-high-level-client-throws-sockettimeoutexception-after-being-idle-for-sometime/188188/4 "2019-08-15T15:41:51Z")

</div>

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