I am getting a java.net.ConnectException: Timeout connecting when I am trying to connect to the ELasticSearch cluster at port 9200.
The error is as follows:
java.net.ConnectException: Timeout connecting to [/172.29.57.160:9200]
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:788)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:218)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:205)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1454)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
at com.ericsson.edos.automation.agent.automationagent.service.LogService.findAll(LogService.java:52)
at com.ericsson.edos.automation.agent.automationagent.service.impl.AutomationServiceImpl.processAutomationLogs(AutomationServiceImpl.java:90)
at com.ericsson.edos.automation.agent.automationagent.scheduler.AutomationScheduler.run(AutomationScheduler.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Timeout connecting to [/172.29.57.160:9200]
at org.apache.http.nio.pool.RouteSpecificPool.timeout(RouteSpecificPool.java:169)
at org.apache.http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIOConnPool.java:628)
at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.timeout(AbstractNIOConnPool.java:894)
at org.apache.http.impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:183)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processTimeouts(DefaultConnectingIOReactor.java:210)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:155)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
... 1 more
Can anyone please suggest what can be done to fix it?
Either use localhost in your code or change network.host setting in your elasticsearch.yml file if you want elasticsearch to be available from other machines.
In our case we were using an older version of Elasticsearch and are only going for 7.3.0. The server port is listening to both 9200/9300. The curl script response for curl -XGET "localhost:9200/_cluster/health?pretty" is:
Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.
Or use markdown style like:
```
CODE
```
This is the icon to use if you are not using markdown format:
There's a live preview panel for exactly this reasons.
Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.
Your cluster is up, is you execute to allow rellocation of al the shards probably the cluster state change to green. This "unassigned_shards" : 56 are probably the replicas.
cluster.routing.allocation.enable
Enable or disable allocation for specific kinds of shards:
all - (default) Allows shard allocation for all kinds of shards.
primaries - Allows shard allocation only for primary shards.
new_primaries - Allows shard allocation only for primary shards for new indices.
none - No shard allocations of any kind are allowed for any indices.
if you execute that you receive the actual configuration
curl -X GET "localhost:9200/_cluster/settings?pretty"
Here where you have the tag "enable": "all" you have "primaries"
About the connection error, all the nodes in your cluster have the same elasticsearch version? In the update process you are following the steps for rolling upgrades?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.