maxFrameLength in DelimiterBasedFrameDecoder and LengthFieldBasedFrameDecoder
aaron.riekenberg
aaron.riekenberg at gmail.com
Sun Aug 14 10:07:09 EDT 2011
I recently began using Netty after some experience with MINA and am
appreciating the many useful encoder and decoder classes such as
DelimiterBasedFrameDecoder and LengthFieldBasedFrameDecoder.
I have a question about the maxFrameLength parameter in both though. In
DelimiterBasedFrameDecoder, if more the maxFrameLength bytes are read before
finding a delimiter the code sets discardingTooLongFrame to true and
continues reading until a delimiter is found. Once the delimiter is found
it throws TooLongFrameException. Suppose the delimiter is never received.
In this case DelimiterBasedFrameDecoder will continue trying to read forever
and will never throw an exception.
There is a TODO in the code saying it would be good to let the user choose
when the exception is raised - initially when discardingTooLongFrame is set
to true or later when the delimiter is found. In my situation I would
prefer the first option - tell me immediately if the frame has grown too
long so I can reset the connection, rather than waiting for a delimiter that
may never come.
I think LengthFieldBasedFrameDecoder has this same issue (and it has the
same TODO comment). It will always try to read the entire too-long frame
before raising an exception. If the length field is set very large this
could take an extremely long time or never happen.
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/maxFrameLength-in-DelimiterBasedFrameDecoder-and-LengthFieldBasedFrameDecoder-tp6684985p6684985.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list