# Timout error when using Rest Client multiple times in production

**URL:** <https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440>\
**Category:** Elasticsearch\
**Created:** [September 6, 2019, 2:48pm UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440 "2019-09-06T14:48:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![venky003](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@venky003](https://discuss.elastic.co/u/venky003)\
**Post date:** [September 6, 2019, 2:48pm UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440/1 "2019-09-06T14:48:56Z")

</div>

```
public RestClient build() {
            if (this.failureListener == null) {
                this.failureListener = new FailureListener();
            }
            CloseableHttpAsyncClient httpClient = this.createHttpClient();
            RestClient restClient = new RestClient(httpClient, (long)this.maxRetryTimeout, this.defaultHeaders, this.hosts, this.pathPrefix, this.failureListener);
            httpClient.start();
            return restClient;
        }

```

com.repository.exception.RepositoryServicesException: java.lang.RuntimeException: error while performing request  
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

```
at com...enterpriseimaging.documentapi.service.impl.DocumentSearchServiceImpl$$EnhancerBySpringCGLIB$$83151592.searchDocument(<generated>) ~[classes!/:0.0.739]

at com...enterpriseimaging.documentapi.rest.v3.DocumentResource.lambda$asyncGetList$2(DocumentResource.java:166) ~[classes!/:0.0.739]

at com.....engine.core.concurrent.FunctionRequestContextHandlerBaseImpl.copyScope(FunctionRequestContextHandlerBaseImpl.java:50) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at com.....engine.core.concurrent.FunctionRequestContextHandlerBaseImpl.copyScope(FunctionRequestContextHandlerBaseImpl.java:64) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at com.....engine.core.concurrent.RequestContextAwareCallable.call(RequestContextAwareCallable.java:57) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_191]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]

Caused by: java.lang.RuntimeException: error while performing request

at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:681) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:219) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:191) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:396) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:382) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:323) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at com...enterpriseimaging.repository.dao.impl.RepositoryDAOImpl.executeRestSearchQuery(RepositoryDAOImpl.java:268) ~[ei-repository-library-0.0.68.jar!/:?]

at com...enterpriseimaging.repository.dao.impl.RepositoryDAOImpl.lambda$searchRepository$0(RepositoryDAOImpl.java:132) ~[ei-repository-library-0.0.68.jar!/:?]

at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) ~[?:1.8.0_191]

... 1 more
Caused by: java.util.concurrent.TimeoutException

        at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:364) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.nio.pool.AbstractNIOConnPool.processNextPendingRequest(AbstractNIOConnPool.java:344) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.nio.pool.AbstractNIOConnPool.release(AbstractNIOConnPool.java:318) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.releaseConnection(PoolingNHttpClientConnectionManager.java:391) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.releaseConnection(AbstractClientExchangeHandler.java:245) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.impl.nio.client.MainClientExec.responseCompleted(MainClientExec.java:387) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:172) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39) ~[httpasyncclient-4.1.4.jar!/:4.1.4]

        at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588) ~[httpcore-nio-4.4.5.jar!/:4.4.5]

        ... 1 more

```

What is timing out in this error. It is timing out to connect to Elastic?

---

<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:** [September 13, 2019, 11:38am UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440/2 "2019-09-13T11:38:27Z")

</div>

Hard to tell with the little info that you provided, but it could be that it's timing out connecting to Elastic. The version that you are using is a bit outdated in the way timeouts are handled though. I would recommend to update the low-level client version that you are using. If you use only low-level client, its version does not have to match the server version.

---

<div class="post-metadata">

**Author:** ![venky003](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@venky003](https://discuss.elastic.co/u/venky003)\
**Post date:** [September 19, 2019, 3:53pm UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440/3 "2019-09-19T15:53:02Z")

</div>

We are using Rest High level client. It is same for High level client, version does not have to match the server version?

---

<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:** [September 23, 2019, 9:03am UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440/4 "2019-09-23T09:03:13Z")

</div>

I thought you were using the low-level client. If you are using the high-level client, the client version does matter and needs to match the server version.

What do you mean with "using rest client multiple times in production" ? Do you create multiple instances of the client in your application?

---

<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:** [October 21, 2019, 9:03am UTC](https://discuss.elastic.co/t/timout-error-when-using-rest-client-multiple-times-in-production/198440/5 "2019-10-21T09:03:18Z")

</div>

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