ElasticSearch 开发总结(六)—exception caught on transport layer[....]closing connection

elasticsearch集群版本5.6.10,Java代码中Maven引入版本5.6.10,使用TransportClient连接ES集群,出现这个错误:

[2019-03-10T15:16:21,269][WARN ][o.e.t.n.Netty4Transport  ] [master] exception caught on transport layer [[id: 0x0844f145, L:/127.0.0.1:9300 - R:/127.0.0.1:58381]], closing connection
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
	at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:?]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276) ~[?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:245) ~[?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:223) ~[?:?]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358) ~[?:?]
	at io.netty.buffer.PooledHeapByteBuf.setBytes(PooledHeapByteBuf.java:261) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) ~[netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:544) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.13.Final.jar:4.1.13.Final]
	at java.lang.Thread.run(Thread.java:834) [?:?]

1.出现这个错误,经过各种搜索,发现应该是版本不一致引起的问题

(1)虽然,集群版本和代码版本是一致的,但是引用其他包可能造成了冲突;

(2)如果项目是Maven管理,建议使用推荐 11个Idea 免费实用插件及插件离线安装方法中“(7)MavenRunHelper”插件监测冲突;

 

2.若错误日志后有以下错误

java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.6.10]

 这个直接就能看出是包冲突引起的问题。 

 

3.其他问题

本地进行单步调试,调用获取client方法。用main函数调用时,函数调用完成、主线程调用结束,集群也会报一个上述错误。

这也说明,获取client后不要随便关闭线程,让线程结束调用,如果需要可以调用关闭函数,之后结束线程调用。

你可能感兴趣的:(ElasticSearch,ElasticSearch,transport,transport,layer)