Hi,
I am getting error while connecting to elasticSearch using HighLeavelClient.
My elastic Search instance is Running on localhost with bind and publish address 127.0.0.1:9200 and is working fine with Postman (I have created one index and added a document as well) . But when I am trying to create connection using java code using HTTPHighLevelClient I am getting "IOException java.net.ConnectException: Connection refused" error. I have tested using both localhost and 127.0.0.1 IP in code -
new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",
9200, "http"), new HttpHost("localhost", 9201, "http")));
elastic search console Logs -
[2019-04-23T10:53:34,289][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [INGGNLAP0270] Failed to clear cache for realms [[]]
[2019-04-23T10:53:34,323][INFO ][o.e.l.LicenseService ] [INGGNLAP0270] license [e78802c4-9436-42a3-9a61-be9068b90684] mode [basic] - valid
[2019-04-23T10:53:34,330][INFO ][o.e.g.GatewayService ] [INGGNLAP0270] recovered [1] indices into cluster_state
[2019-04-23T10:53:34,704][INFO ][o.e.c.r.a.AllocationService] [INGGNLAP0270] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[audit][0]] ...]).
[2019-04-23T10:53:35,070][INFO ][o.e.h.AbstractHttpServerTransport] [INGGNLAP0270] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2019-04-23T10:53:35,071][INFO ][o.e.n.Node ] [INGGNLAP0270] started
I checked in elasticSearch logs , I found the following -
org.elasticsearch.transport.RemoteTransportException: [][10.0.75.1:9300][internal:cluster/coordination/join]
Caused by: org.elasticsearch.cluster.coordination.CoordinationStateRejectedException: incoming term 5 does not match current term 6
at org.elasticsearch.cluster.coordination.CoordinationState.handleJoin(CoordinationState.java:218) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.coordination.Coordinator.handleJoin(Coordinator.java:940) ~[elasticsearch-7.0.0.jar:7.0.0]
at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_211]
at org.elasticsearch.cluster.coordination.Coordinator.processJoinRequest(Coordinator.java:512) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.coordination.Coordinator.handleJoinRequest(Coordinator.java:478) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.coordination.JoinHelper.lambda$new$0(JoinHelper.java:124) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler$1.doRun(SecurityServerTransportInterceptor.java:251) [x-pack-security-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler.messageReceived(SecurityServerTransportInterceptor.java:309) [x-pack-security-7.0.0.jar:7.0.0]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:63) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:687) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.0.jar:7.0.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_211]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_211]
Any Help is highly appreciated.