IllegalStateException in FrameDecoder
"이희승 (Trustin Lee)"
trustin at gmail.com
Thu May 26 09:39:08 EDT 2011
I find a couple issues:
1) ChannelBuffer.bytesBefore() returns the number of bytes instead of an
index. Therefore, indexOfHeader should be renamed to
'bytesBeforeHeader' or something similar, and
buffer.readerIndex(indexOfHeader) should be replaced with
buffer.skipBytes(bytesBeforeHeader)
2) After header is read and readerIndex advances, you check if there are
enough bytes in the buffer for the message body, and just return when
there are not enough bytes. Because you advanced the readerIndex
already for the header, the header will be lost next time decode() is
called.
3) You don't need to call discardReadBytes(). I think this might
confuse FrameDecoder.
On 05/26/2011 10:15 PM, Abraham Menacherry wrote:
> Trustin,
>
> Thanks for the detailed explanation. Could the following situation have
> caused it?
> 1) I read header bytes, advance the reader index and return.
> 2) I am expecting some body bytes of certain length.
> 3) I do buffer.readableBytes()>= expectedLen and find that it is not
> enough.
> 4) I return null.
> Note: Step 1 may not return if all the available bytes are there. Attaching
> the decoder file for reference.
>
> Thanks,
> Abraham.
> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/file/n6406944/DeviceProtocolMultiplexer.java
> DeviceProtocolMultiplexer.java
>
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/IllegalStateException-in-FrameDecoder-tp6406604p6406944.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee, http://gleamynode.net/
More information about the netty-users
mailing list