使用found连接到使用SSL的elasticsearch

时间:2016-07-04 08:45:16

标签: java ssl elasticsearch

我尝试通过SSL连接到我的弹性搜索服务器并尝试了很多不同的东西,但无法解决问题。 目前我正在使用elasticsearch 2.3.3和jdk1.7.0_79。

编辑:首先,我尝试使用以下代码在Netbeans中使用Elastic JAVA Api进行连接:

Settings settings = Settings.settingsBuilder()
    .put("cluster.name", CLUSTER_NAME)
    .put("shield.user", "USER:PASSWORD")
    .put("transport.ssl.keystore.path", "/usr/share/elasticsearch/bin/shield/KEYSTORE.jks")
    .put("transport.ssl.keystore.keystore_password", KEYSTORE_PASSWORD)
    .put("shield.transport.ssl", true).build();

Client client = TransportClient.builder().settings(settings).build()
    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(HOST), 9300));

上一个示例适用于我的弹性localhost服务器,但是当我尝试将其迁移到使用SSL的Web服务器时,它每隔5秒输出一次:

976 [main] DEBUG org.elasticsearch.client.transport  - [Miguel Espinosa] adding address [{#transport#-1}{IP_ADDRESS}{HOST/IP_ADDRESS:9300}]
1059 [main] DEBUG org.elasticsearch.transport.netty  - [Miguel Espinosa] connected to node [{#transport#-1}{IP_ADDRESS}{HOST/IP_ADDRESS:9300}]
1200 [elasticsearch[Miguel Espinosa][generic][T#1]] DEBUG org.elasticsearch.transport.netty  - [Miguel Espinosa] disconnecting from [{#transport#-1}{IP_ADDRESS}{HOST/IP_ADDRESS:9300}], channel closed event
1238 [main] INFO org.elasticsearch.client.transport  - [Miguel Espinosa] failed to get node info for {#transport#-1}{IP_ADDRESS}{HOST/IP_ADDRESS:9300}, disconnecting...
NodeDisconnectedException[[][HOST/IP_ADDRESS:9300][cluster:monitor/nodes/liveness] disconnected]  

之后,现在我尝试使用found-shield尝试连接弹性,但是当我运行应该工作的示例时,它会输出以下内容:

[2016-07-04 08:38:10,455][INFO ][no.found.elasticsearch.example.TransportExample] Connecting to cluster: [CLUSTER_ID] via [CLUSTER_ID.REGION.aws.found.io:9343] using ssl:[true]
[2016-07-04 08:38:10,688][INFO ][org.elasticsearch.plugins] [Neuronne] modules [], plugins [shield], sites []
[2016-07-04 08:38:10,983][INFO ][org.elasticsearch.transport] [Neuronne] Using [org.elasticsearch.shield.transport.ShieldClientTransportService] as transport service, overridden by [shield]
[2016-07-04 08:38:10,987][INFO ][org.elasticsearch.transport] [Neuronne] Using [org.elasticsearch.shield.transport.netty.ShieldNettyTransport] as transport, overridden by [shield]
[2016-07-04 08:38:12,051][INFO ][org.elasticsearch.client.transport] [Neuronne] failed to get node info for {#transport#-1}{IP_ADDRESS}{CLUSTER_ID.REGION.aws.found.io/IP_ADDRESS:9343}, disconnecting...
org.elasticsearch.transport.RemoteTransportException: [Failed to deserialize exception response from stream]
org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
        at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:200) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:136) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[netty-3.10.5.Final.jar:na]
        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[netty-3.10.5.Final.jar:na]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_79]
        at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_79]
Caused by: java.io.IOException: failed to read exception for id [40]
        at org.elasticsearch.ElasticsearchException.readException(ElasticsearchException.java:246) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.common.io.stream.StreamInput.readThrowable(StreamInput.java:506) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:198) ~[elasticsearch-2.3.3.jar:2.3.3]
        ... 30 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_79]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_79]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_79]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_79]
        at org.elasticsearch.ElasticsearchException.readException(ElasticsearchException.java:244) ~[elasticsearch-2.3.3.jar:2.3.3]
        ... 32 common frames omitted
Caused by: java.lang.IndexOutOfBoundsException: Readable byte limit exceeded: 118
        at org.jboss.netty.buffer.AbstractChannelBuffer.readByte(AbstractChannelBuffer.java:236) ~[netty-3.10.5.Final.jar:na]
        at org.elasticsearch.transport.netty.ChannelBufferStreamInput.readByte(ChannelBufferStreamInput.java:132) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.common.io.stream.StreamInput.readString(StreamInput.java:254) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.common.io.stream.StreamInput.readOptionalString(StreamInput.java:233) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.ElasticsearchException.<init>(ElasticsearchException.java:88) ~[elasticsearch-2.3.3.jar:2.3.3]
        at org.elasticsearch.index.query.QueryParsingException.<init>(QueryParsingException.java:114) ~[elasticsearch-2.3.3.jar:2.3.3]
        ... 37 common frames omitted

我是弹性搜索的新手,所以如果有什么不合适请问我,我会尽快给你提供。 我还检查了其他类似问题,例如SSL Elasticsearch

谢谢,伊曼纽尔

1 个答案:

答案 0 :(得分:0)

如文档中所述,您应该同步JDK版本:

  

在Elasticsearch的少数几个位置,使用了Java的本机序列化   (IP地址,例外等)。不幸的是,Oracle有   众所周知,改变次要版本之间的序列化格式,   导致奇怪的错误。这很少发生,但最好   练习使客户端和服务器之间的JVM版本保持一致。

您可以阅读更多here