Error while sniffing nodes

Environment:

  • JDK 1.8.0_301
  • Grails 5.0.2
  • Spring Boot 2.5.7
  • Groovy 3.0.7
  • Elasticsearch 7.10.2 (also tried 7.12.1)

Situation:
Hi dear colleagues, could you please clarify the error while sniffing nodes.

Task:
Running successfully Gateway service which is using management health check internally designed by Spring

Actions:
Found here asked before but seems log wasn't provided fully.

Result
Facing the following error:

2021-12-08 06:29:17.245 ERROR 7688 --- [nt_sniffer[T#1]] org.elasticsearch.client.sniff.Sniffer   : error while sniffing nodes

java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]
	at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:880) ~[elasticsearch-rest-client-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:283) ~[elasticsearch-rest-client-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270) ~[elasticsearch-rest-client-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.sniff.ElasticsearchNodesSniffer.sniff(ElasticsearchNodesSniffer.java:105) ~[elasticsearch-rest-client-sniffer-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.sniff.Sniffer.sniff(Sniffer.java:208) ~[elasticsearch-rest-client-sniffer-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.sniff.Sniffer$Task.run(Sniffer.java:138) ~[elasticsearch-rest-client-sniffer-7.12.1.jar:7.12.1]
	at org.elasticsearch.client.sniff.Sniffer$1.run(Sniffer.java:81) [elasticsearch-rest-client-sniffer-7.12.1.jar:7.12.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_301]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_301]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_301]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_301]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_301]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_301]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_301]
Caused by: java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]
	at org.apache.http.nio.pool.RouteSpecificPool.timeout(RouteSpecificPool.java:169) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIOConnPool.java:632) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.timeout(AbstractNIOConnPool.java:898) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:198) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processTimeouts(DefaultConnectingIOReactor.java:213) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:158) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351) ~[httpcore-nio-4.4.14.jar:4.4.14]
	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221) ~[httpasyncclient-4.1.4.jar:4.1.4]
	at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.4.jar:4.1.4]
	... 1 common frames omitted

Thanks in advance

The connection timeout and socket timeout are configured with value 60000.
As soon as using locally running Elasticsearch container after application startup getting another error

java.net.SocketTimeoutException: 30,000 milliseconds timeout on connection http-outgoing-0 [ACTIVE]
	at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:865)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:283)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270)
	at org.elasticsearch.client.sniff.ElasticsearchNodesSniffer.sniff(ElasticsearchNodesSniffer.java:105)
	at org.elasticsearch.client.sniff.Sniffer.sniff(Sniffer.java:208)
	at org.elasticsearch.client.sniff.Sniffer$Task.run(Sniffer.java:138)
	at org.elasticsearch.client.sniff.Sniffer$1.run(Sniffer.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketTimeoutException: 30,000 milliseconds timeout on connection http-outgoing-0 [ACTIVE]
	at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.timeout(HttpAsyncRequestExecutor.java:387)
	at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:92)
	at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:39)
	at org.apache.http.impl.nio.reactor.AbstractIODispatch.timeout(AbstractIODispatch.java:175)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionTimedOut(BaseIOReactor.java:261)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.timeoutCheck(AbstractIOReactor.java:502)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:211)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
	... 1 common frames omitted

My Configurations are following

new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host, port, "http")).setRequestConfigCallback(
                            new RestClientBuilder.RequestConfigCallback() {
                                @Override
                                RequestConfig.Builder customizeRequestConfig(
                                        RequestConfig.Builder requestConfigBuilder) {
                                            return requestConfigBuilder
                                                    .setConnectTimeout(60000)
                                                    .setSocketTimeout(60000)
                                        }
                                }))

Excluded Elasticsearch autoconfiguration which is included by default, solves the issue for now.
My answer approved to disable it.

spring:
  autoconfigure:
    exclude: org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration

stackoverflow answer here

1 Like

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