# RestClient java.lang.RuntimeException: error while performing request

**URL:** <https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078>\
**Category:** Elasticsearch\
**Created:** [April 4, 2017, 5:46am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078 "2017-04-04T05:46:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [April 4, 2017, 5:46am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/1 "2017-04-04T05:46:25Z")

</div>

Hi, Thank you for the great open source!

I am using RestClient(java) to connect elastic cloud for searching.

The program is multi thread environment and each thread can call restclient.

This is error :

java.lang.RuntimeException: error while performing request  
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:681)  
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:219)  
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:191)  
at com.dispatch.workflow.CalcDiffThread.getNearNodes(CalcDiffThread.java:294)  
at com.dispatch.workflow.CalcDiffThread.calcList(CalcDiffThread.java:106)  
at com.dispatch.workflow.CalcDiffThread.calcDiff(CalcDiffThread.java:87)  
at com.dispatch.workflow.CalcDiffThread.call(CalcDiffThread.java:54)  
at com.dispatch.workflow.CalcDiffThread.call(CalcDiffThread.java:1)  
at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)  
Caused by: java.util.concurrent.TimeoutException  
at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:364)  
at org.apache.http.nio.pool.AbstractNIOConnPool.processNextPendingRequest(AbstractNIOConnPool.java:344)  
at org.apache.http.nio.pool.AbstractNIOConnPool.release(AbstractNIOConnPool.java:318)  
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.releaseConnection(PoolingNHttpClientConnectionManager.java:303)  
at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.releaseConnection(AbstractClientExchangeHandler.java:239)  
at org.apache.http.impl.nio.client.MainClientExec.responseCompleted(MainClientExec.java:387)  
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:168)  
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)  
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)  
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)  
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)  
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)  
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)  
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)  
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)  
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)  
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)  
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)  
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)  
... 1 more

* * *

```
<dependencies>
	<dependency>
		<groupId>com.googlecode.json-simple</groupId>
		<artifactId>json-simple</artifactId>
		<version>1.1.1</version>
	</dependency>
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>rest</artifactId>
		<version>5.3.0</version>
	</dependency>
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-to-slf4j</artifactId>
		<version>2.6</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-api</artifactId>
		<version>1.7.21</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-simple</artifactId>
		<version>1.7.21</version>
	</dependency>
	<dependency>
		<groupId>org.apache.mina</groupId>
		<artifactId>mina-core</artifactId>
		<version>2.0.16</version>
	</dependency>
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>x-pack-transport</artifactId>
		<version>5.3.0</version>
	</dependency>
	<dependency>
		<groupId>org.locationtech.spatial4j</groupId>
		<artifactId>spatial4j</artifactId>
		<version>0.6</version>
	</dependency>

	<dependency>
		<groupId>biz.paluch.redis</groupId>
		<artifactId>lettuce</artifactId>
		<version>4.3.0.Final</version>
	</dependency>
	<dependency>
		<groupId>com.amazonaws</groupId>
		<artifactId>amazon-sqs-java-messaging-lib</artifactId>
		<version>1.0.1</version>
		<type>jar</type>
	</dependency>
</dependencies>

```

* * *

If you have any advice on it, please let me know!

Thanks,  
HJ Shin

---

<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 7, 2017, 7:59am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/2 "2017-04-07T07:59:12Z")

</div>

Hi,  
looking at your stacktrace it seems like you have a TimeoutException, which would indicate a timeout when trying to obtain a connection from the connection pool. Do you have that consistently or did it only happen one time?

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [April 8, 2017, 1:23am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/3 "2017-04-08T01:23:20Z")

</div>

Thanks for the replying Luca!

I think same as you.

I guess that this problem happens when threads are huge.

Do you have any idea to calculate right amount of queries based on node spec?

I am currently using elastic cloud.

1 node  
Memory 8 GB  
Storage 192 GB  
SSD Yes  
High availability No

---

<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 10, 2017, 12:35pm UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/4 "2017-04-10T12:35:02Z")

</div>

I don't have enough context to conclude whether this has to do with number of threads and what they do, or just connectivity issues, or? As I asked before, did you have this problem only once in your logs or multiple times? Can you reproduce it and pinpoint it to a load issue?

---

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [April 11, 2017, 8:36am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/5 "2017-04-11T08:36:53Z")

</div>

My system has pattern for usage.

Users are sending their request a lot at sudden time.

Above error happened at this moment so I assume that this problem comes from heavy threads.

I reduced the number of thread pool size and the problem gone.

Thanks for the reply!

---

<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:** [May 9, 2017, 8:49am UTC](https://discuss.elastic.co/t/restclient-java-lang-runtimeexception-error-while-performing-request/81078/6 "2017-05-09T08:49:52Z")

</div>

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