# Restclient fails with concurrent.TimeoutException Exception

**URL:** <https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736>\
**Category:** Elasticsearch\
**Created:** [November 30, 2017, 11:11am UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736 "2017-11-30T11:11:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vyas.radhakrishnan](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@vyas.radhakrishnan](https://discuss.elastic.co/u/vyas.radhakrishnan)\
**Post date:** [November 30, 2017, 11:11am UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/1 "2017-11-30T11:11:20Z")

</div>

Indexing is failing with following exception . I am using Elastic Search REST client 5.6.4 and Elastic Server 5.6.4.  
I saw a similar post , but no resolution given . can i get some pointers ?

Caused by: java.util.concurrent.TimeoutException  
at org.apache.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:375)  
at org.apache.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:277)  
at org.apache.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:268)  
at org.apache.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:377)  
at org.apache.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:129)  
at org.apache.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:141)  
at org.apache.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:343)  
at org.apache.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:325)  
at org.apache.elasticsearch.client.RestClient.performRequest(RestClient.java:218)

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [November 30, 2017, 7:59pm UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/2 "2017-11-30T19:59:26Z")

</div>

Hi Vyas,

Can you post the relevant part of our code (initialization and index operation)? That would help someone to try to figure out what's happening.

Also, can you check if you are connecting in the elasticsearch port (default 9200)?

Cheers,  
LG

---

<div class="post-metadata">

**Author:** ![vyas.radhakrishnan](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@vyas.radhakrishnan](https://discuss.elastic.co/u/vyas.radhakrishnan)\
**Post date:** [December 7, 2017, 10:52am UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/3 "2017-12-07T10:52:55Z")

</div>

Hi Luiz

we initialize rest (Singleton) rest client,

public static Client getRestClient() {  
ADFContext context = ADFContext.getCurrent();   
if (context != null) {   
Map\<String, Object\> applicationScope = context.getApplicationScope()  
Client client = (Client)applicationScope.get(REST\_CLIENT\_CACHE\_KEY);  
if (client == null) {  
client = cacheRestClient(applicationScope);  
}  
return client;  
}  
return null;  
}

yes we use default port , 9200.

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [December 7, 2017, 11:41am UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/4 "2017-12-07T11:41:17Z")

</div>

Hi Vyas,

I didn't get your point precisely. I have one example on how to initialize the low level REST client and perform one index operation in [my gist](https://gist.github.com/luizgpsantos/877f2c4fa0f08de0d5096d84243eef5f).

Does it work for you?

Also, you can find more detailed information in [this doc page](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-initialization.html).

Cheers,  
LG

---

<div class="post-metadata">

**Author:** ![vyas.radhakrishnan](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@vyas.radhakrishnan](https://discuss.elastic.co/u/vyas.radhakrishnan)\
**Post date:** [December 7, 2017, 12:58pm UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/5 "2017-12-07T12:58:00Z")

</div>

Ok , this is what i am doing . No timeout parameters are changed.

public static Client getRestClient(HttpHost host) {  
RestClientBuilder builder = RestClient.builder(host);  
builder.setDefaultHeaders(EMPTY\_HEADERS);  
return new Client(builder.build(), host);  
}  
Note: Above exception is consistent seen all the them time. And we have only 1 Node.

---

<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:** [January 4, 2018, 12:58pm UTC](https://discuss.elastic.co/t/restclient-fails-with-concurrent-timeoutexception-exception/109736/6 "2018-01-04T12:58:03Z")

</div>

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