A few days ago I noticed that my websocket clients are being disconnected in weird way. I found that, when upgrade is complete, exception below is being thrown from HttpResponseDecoder and WebSocketClientProtocolHandler just closes connection on exception. And this happens only if i use pooled allocator for channels.
io.netty.handler.codec.DecoderException: io.netty.util.IllegalReferenceCountException: refCnt: 0
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:391)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:745)
Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0
at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1190)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1176)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1172)
at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:672)
at io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:390)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:360)
... 12 more
System info
Linux Atplaychannel 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Java version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
This happens only when first websocket frame is being received in same packet as upgrade response.
Netty version is 4.0.33.Final and it looks like that previous versions don't have this issue.
Code that reproduces the issue https://gist.github.com/lexek/b61d0980f029f47b353b
A few days ago I noticed that my websocket clients are being disconnected in weird way. I found that, when upgrade is complete, exception below is being thrown from HttpResponseDecoder and WebSocketClientProtocolHandler just closes connection on exception. And this happens only if i use pooled allocator for channels.
System info
Java version
This happens only when first websocket frame is being received in same packet as upgrade response.
Netty version is 4.0.33.Final and it looks like that previous versions don't have this issue.
Code that reproduces the issue https://gist.github.com/lexek/b61d0980f029f47b353b