netty支持linux的epoll是4.0.17.Final引入的新功能,不过测试使用发现几个bug。暂记如下:
[已解决的]
使用epoll时channel关闭错误
1 2 |
java.nio.channels.ClosedChannelException: null at io.netty.channel.epoll.Native.readAddress(Native Method) |
原因:Native.finishConnect()中有bug
见这里:https://github.com/netty/netty/issues/2280
下载最新代码编译package可解决。包括编译Native的c代码:
1 |
gcc -fPIC -shared -o libnetty-transport-native-epoll.so -I/jdk/include/ io_netty_channel_epoll_Native.c |
[未解决的]
使用epoll时channel中取不到localAddress()和remoteAddress()
1 2 3 4 |
Channel channel = channelHandlerContext.channel(); log.warn("channel {} isActive {}", channel, channel.isActive()); log.warn("localAddress {}", channel.localAddress()); log.warn("remoteAddress {}", channel.remoteAddress()); |
log:
1 2 3 |
18:10:27.076 176719 [nioEventLoopGroup-5-1] WARN c.v.b.c.ClientChannelNetty4Impl [118] - channel [id: 0x892e0c3c] isActive true 18:10:27.077 176720 [nioEventLoopGroup-5-1] WARN c.v.b.c.ClientChannelNetty4Impl [119] - localAddress null 18:10:27.077 176720 [nioEventLoopGroup-5-1] WARN c.v.b.c.ClientChannelNetty4Impl [120] - remoteAddress null |
github上有相关的issue: https://github.com/netty/netty/issues/2262
虽然标记为已解决,但编译4.0最新的代码(4.0.18.Final-SNAPSHOT)错误仍在。
先记录下,明天再来看怎么回事。