I'm a little stuck figuring out why I'm getting a handshake failure when trying to connect to ES. I ran ES with the following command:
docker run -e ES_JAVA_OPTS='-Xms1g -Xmx1g' --name elasticsearch -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -d -p 9200:9200 -p 9300:9300 docker.elastic.co/elasticsearch/elasticsearch:5.2.2
When I access ES from the browser at localhost:9200, I get:
"name": "zW-D1Xo",
"cluster_name": "docker-cluster",
"cluster_uuid": "j9DGTipFSB6qC5P-LWvxPQ",
"version": {
"number": "5.2.2",
"build_hash": "f9d9b74",
"build_date": "2017-02-24T17:26:45.835Z",
"build_snapshot": false,
"lucene_version": "6.4.1"
},
"tagline": "You Know, for Search"
}
I set up the TransportClient like so:
transportClient = new PreBuiltTransportClient(settingsBuilder.build())
.addTransportAddresses(transportAddresses);
The only setting is cluster.name.
The error I get is this:
INFO [2017-04-18 21:38:31,593] org.elasticsearch.client.transport.TransportClientNodesService: failed to connect to node [{#transport#-1}{oFK78nJYT9-FGrQbHEk-qg}{localhost}{127.0.0.1:9300}], removed from nodes list
! org.elasticsearch.transport.TransportException: connection reset
! at org.elasticsearch.transport.TcpTransport.onChannelClosed(TcpTransport.java:1610)
! at org.elasticsearch.transport.netty4.Netty4Transport.access$100(Netty4Transport.java:93)
! at org.elasticsearch.transport.netty4.Netty4Transport$ChannelCloseListener.operationComplete(Netty4Transport.java:412)
! at org.elasticsearch.transport.netty4.Netty4Transport$ChannelCloseListener.operationComplete(Netty4Transport.java:402)
! at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
! at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:481)
! at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
! at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
! at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)
! at io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:1058)
! at io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:686)
! at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:664)
! at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:607)
! at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.closeOnRead(AbstractNioByteChannel.java:82)
! at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:137)
! at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
! at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:527)
! at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:481)
! at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
! at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
! ... 1 common frames omitted
! Causing: java.lang.IllegalStateException: handshake failed
! at org.elasticsearch.transport.TcpTransport.executeHandshake(TcpTransport.java:1568)
! at org.elasticsearch.transport.TcpTransport.openConnection(TcpTransport.java:502)
! ... 9 common frames omitted
! Causing: org.elasticsearch.transport.ConnectTransportException: [][127.0.0.1:9300] general node connection failure
! at org.elasticsearch.transport.TcpTransport.openConnection(TcpTransport.java:519)
! at org.elasticsearch.transport.TcpTransport.connectToNode(TcpTransport.java:460)
! at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:318)
! at org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.doSample(TransportClientNodesService.java:408)
! at org.elasticsearch.client.transport.TransportClientNodesService$NodeSampler.sample(TransportClientNodesService.java:354)
! at org.elasticsearch.client.transport.TransportClientNodesService$ScheduledNodeSampler.run(TransportClientNodesService.java:387)
! at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:527)
! 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)
Here is the Maven dependency (where dep.es.version is 5.2.2):
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${dep.es.version}</version>
<exclusions>
<exclusion>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${dep.es.version}</version>
<exclusions>
<exclusion>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
</dependency>
I don't know what I should try next. Any ideas or directions I should pursue?
Thanks,
Benson