Java client 7.6.2 socket timeout seems has problem

    RestClientBuilder builder = RestClient.builder(httpHostArray)
            .setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder
                    .setConnectTimeout(connectTimeout)
                    .setSocketTimeout(socketTimeout)
                    .setConnectionRequestTimeout(requestTimeout));

socketTimeout = 3000

then RestClient.performRequest(RestClient.java:251) run many times

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

how can i solve this

Caused by: java.net.SocketTimeoutException: 3,000 milliseconds timeout on connection http-outgoing-2038 [ACTIVE]
	at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:808) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:248) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1514) ~[elasticsearch-rest-high-level-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1484) ~[elasticsearch-rest-high-level-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1454) ~[elasticsearch-rest-high-level-client-7.6.2.jar!/:7.6.2]
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:970) ~[elasticsearch-rest-high-level-client-7.6.2.jar!/:7.6.2]
	at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.lambda$search$10(ElasticsearchRestTemplate.java:269) ~[spring-data-elasticsearch-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
	at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.execute(ElasticsearchRestTemplate.java:359) ~[spring-data-elasticsearch-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
	... 13 more
	Suppressed: java.net.SocketTimeoutException: 3,000 milliseconds timeout on connection http-outgoing-2037 [ACTIVE]
		at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:808) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:248) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:251) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235) ~[elasticsearch-rest-client-7.6.2.jar!/:7.6.2]
		at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1514) ~[elasticsearch-rest-high-level-client-7.6.2.jar!/:7.6.2]

Hello and welcome!
It seems like a socket timeout of 3 seconds is not enough for the server to send the response, the default value is 30000, which is 30 seconds. Could you try increasing the value?

default value can not solve this

Do you get the same exception using 30000 as the value?

I'd also upgrade to 7.17.

1 Like