Azure / Azure/DotNetty

LengthFieldBasedFrameDecoder can not keep working

Open
#335 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.3k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I use LengthFieldBasedFrameDecoder for parsing data packact,
pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 1, 2, 3, 4));
the packact look like "68 00 07 68 FF FF 01 49 84 00 05 D1 16”
68 header1 =========== 1byte
00 07 ength============2byte
68 header2 ===========1byte
FF FF 01 49 84 00 05 data====7byte
D1 checksum===========1byte
16 end flag=============1byte
issue:
1、checksum and flag,the last bytes length is 2,why the lengthAdjustment in LengthFieldBasedFrameDecoder() must be 3??
2、if i keep sending a error packet such like "68 00 07 68 FF FF 01 49 84 00 05 D1 16 11 12” ,
I can parse it correctly first time ,but after then,ChannelRead will never be called.
the following is my code
public class GPRSServerHandler : ChannelHandlerAdapter
{
public override void ChannelRead(IChannelHandlerContext context, object message)
{
var buffer = message as IByteBuffer;
if (buffer != null)
{
var data = new byte[buffer.ReadableBytes];
buffer.ReadBytes(data);
Console.WriteLine("Received from client: " + BitConverter.ToString(data));
}
}
}
To solve the problem,What should I do?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.