Repository navigation
Closed
Description
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
Activity
normanmaurer commentedon Dec 29, 2015
@lexek will have a look
normanmaurer commentedon Dec 29, 2015
@lexek what websockets version ?
lexek commentedon Dec 29, 2015
@normanmaurer v13
normanmaurer commentedon Dec 29, 2015
@lexek so far not luck reproduce it with your code on linux and OS X :(
lexek commentedon Dec 29, 2015
@normanmaurer is channel getting closed right with first websocket frame? I had to put logging handler before websocket handler to see the exception itself, because webscocket handler closes channel silently on any exception, sorry I din't mention that. Updated gist too.
normanmaurer commentedon Dec 29, 2015
@lexek was able to reproduce it one time now. I think I know what the issue is... let me try to write a unit test and a fix.
[#4635] Stop decoding if decoder was removed
normanmaurer commentedon Jan 4, 2016
@lexek please test #4651
lexek commentedon Jan 4, 2016
@normanmaurer tested and looks like it is fixed
normanmaurer commentedon Jan 4, 2016
@lexek thanks for verify!
[#4635] Stop decoding if decoder was removed
[#4635] Stop decoding if decoder was removed
normanmaurer commentedon Jan 5, 2016
Fixed by #4651
[#4635] Stop decoding if decoder was removed in ReplayingDecoder
[#4635] Stop decoding if decoder was removed in ReplayingDecoder
[#4635] Stop decoding if decoder was removed in ReplayingDecoder
[netty#4635] Stop decoding if decoder was removed
[netty#4635] Stop decoding if decoder was removed in ReplayingDecoder