Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于DelimiterBasedFrameDecoder的一点concern #1

Closed
Hailei opened this issue Sep 21, 2012 · 3 comments
Closed

关于DelimiterBasedFrameDecoder的一点concern #1

Hailei opened this issue Sep 21, 2012 · 3 comments

Comments

@Hailei
Copy link

Hailei commented Sep 21, 2012

关于DelimiterBasedFrameDecoder的一点concern 使用nio read的时候一般是多次累积读才能读完整的一帧,如使用DelimiterBasedFrameDecoder,读到制定的边界符才算是完整的一帧,例如一帧有1000byte,第一次只读到了200byte,这时decode返回null,在随后的SocketHandler中
ByteBuffer buffer = ((ChannelBuffer)e.getMessage()).toByteBuffer();
会抛出异常然后向client写协议异常。其实并不是真的协议异常,只是因为某种原因没有读完整,不知你们在使用中存在这样的问题吗

@58code
Copy link
Owner

58code commented Sep 21, 2012

可以设置netty参数进行处理
child.receiveBufferSize
child.sendBufferSize

@Hailei
Copy link
Author

Hailei commented Sep 24, 2012

设置child.receiveBufferSize child.sendBufferSize解决不了这个问题。或者我这个场景描述的不对,换另外一个场景。
Netty自己有一个读写控制,AdaptiveReceiveBufferSizePredictor初始读buffer的大小为1024,假如我们每一帧大小为100,这样处理第11帧的时候,只能读到24b,显然不包含边界符而返回null。在sockethandler中就会NullPointException。这显然不是协议异常,而是需要等待读取足够的数据。

@Hailei
Copy link
Author

Hailei commented Oct 17, 2012

呵呵! 我的担心是多余的。当FrameDecoder的解析到的对象为null是不会fire到 PipeLine的下一个handler

@Hailei Hailei closed this as completed Oct 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants