以前,我们使用Netty 4.0.0.Alpha7来开发我们的Websocket应用程序,一切正常。一旦Netty 4.0.0.Beta1发布,我们就将它们整合到我们的应用程序中。但是,没有客户端可以连接到该应用程序。最初,我认为这是我们的问题,所以我们从github获取websocket示例,它也不起作用。
奇怪的是我们的应用程序和示例在我们在本地计算机上运行时可以正常工作但是,一旦部署到我们的服务器,它就不起作用。当我们在同一台服务器上回滚到Netty Alpha7时,它再次正常工作。有人遇到过这种问题吗?
我在服务器(Linux)中运行Websocket示例时发现了异常。我在本地计算机上运行时找不到此异常(Windows7)
io.netty.channel.ChannelPipelineException: io.netty.buffer.IllegalBufferAccessException
at io.netty.channel.DefaultChannelPipeline.notifyHandlerException(DefaultChannelPipeline.java:1019)
at io.netty.channel.DefaultChannelHandlerContext.freeHandlerBuffersAfterRemoval(DefaultChannelHandlerContext.java:360)
at io.netty.channel.DefaultChannelHandlerContext.invokeInboundBufferUpdated(DefaultChannelHandlerContext.java:962)
at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated0(DefaultChannelHandlerContext.java:926)
at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated(DefaultChannelHandlerContext.java:904)
at io.netty.channel.DefaultChannelPipeline.fireInboundBufferUpdated(DefaultChannelPipeline.java:909)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:115)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:401)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:365)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:302)
at io.netty.channel.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110)
at java.lang.Thread.run(Thread.java:619)
Caused by: io.netty.buffer.IllegalBufferAccessException
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:81)
at io.netty.channel.ChannelInboundByteHandlerAdapter.freeInboundBuffer(ChannelInboundByteHandlerAdapter.java:46)
at io.netty.channel.DefaultChannelHandlerContext.freeHandlerBuffersAfterRemoval(DefaultChannelHandlerContext.java:358)
... 10 more
io.netty.channel.ChannelPipelineException: io.netty.buffer.IllegalBufferAccessException
at io.netty.channel.DefaultChannelPipeline.notifyHandlerException(DefaultChannelPipeline.java:1019)
at io.netty.channel.DefaultChannelHandlerContext.freeHandlerBuffersAfterRemoval(DefaultChannelHandlerContext.java:360)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:823)
at io.netty.channel.DefaultChannelHandlerContext.access$1300(DefaultChannelHandlerContext.java:38)
at io.netty.channel.DefaultChannelHandlerContext$5.run(DefaultChannelHandlerContext.java:808)
at io.netty.channel.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:259)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:305)
at io.netty.channel.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110)
at java.lang.Thread.run(Thread.java:619)
Caused by: io.netty.buffer.IllegalBufferAccessException
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:81)
at io.netty.channel.ChannelInboundByteHandlerAdapter.freeInboundBuffer(ChannelInboundByteHandlerAdapter.java:46)
at io.netty.channel.DefaultChannelHandlerContext.freeHandlerBuffersAfterRemoval(DefaultChannelHandlerContext.java:358)
... 7 more
更新,似乎这是java版本的问题。最初,java版本是6u17,应用程序不起作用。我将它更新到6u38后,应用程序运行正常。
答案 0 :(得分:0)
好的我猜你从ChannelPipeline中删除ChannelHandler后尝试访问缓冲区。这是不允许的,因为Beta1确保我们不会在删除时泄漏任何内存。如果你想删除ChannelHandler并将缓冲区中的剩余内容转发到ChannelPipeline中的下一个ChannelHandler,请使用ChannelPipeline.removeAndForward(..)。
另见: https://github.com/netty/netty/issues/1054#issuecomment-13760528