I got a strange error when using netty(with camel), we use LengthFieldBasedFrameDecoder for communication, client is a socket program from third party, we use netty(camel-netty component) on the server side.
sometimes got two messages “merged” into one, and hence the forthcoming data get all wrong.
for example:
client send two messages:
[10]AAAAAAAAAAAAAAAA
and
[10]BBBBBBBBBBBBBBBB
where [10] is the length bytes and AAAAAAAAAA is the data.
but on the server we got
[10]AAAAAA[10]BBBBBBBBBBBBBBBBAAAAAAAAAA
seems the the first message got split by the second one, so the decoder interpreted the data as:
[10]AAAAAA[10]BBBBBBBB
and
BBBBBBBBAAAAAAAAAA……………………………………………
so that the first message is correct in length but wrong in data, and the second message is wrong in length “BB”, and get a much longer data packet.
hope I described clearly, anyone met this before?
well, this proved to be a “bug” of camel-netty component, I will post a fix to camel project later on. Before that, please be careful using the camel-netty component, especially do not use encoders/decoders not mark with @sharable annotation, it will lead to the problem since state maybe shared among different connections.