Stop receiving requests
Shay Banon
kimchy at gmail.com
Wed May 12 14:41:37 EDT 2010
Hi,
I have a problem and am trying to find the best solution for. In netty, I
am using a FrameDecoder that simply does the following:
protected Object decode(ChannelHandlerContext ctx, Channel channel,
ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() < 4) {
return null;
}
int dataLen = buffer.getInt(buffer.readerIndex());
if (dataLen <= 0) {
throw new StreamCorruptedException("invalid data length: " +
dataLen);
}
if (buffer.readableBytes() < dataLen + 4) {
return null;
}
buffer.skipBytes(4);
return buffer;
}
On the next handler, I use the buffer to extract the request from (and other
information). The problem I have is that something might fail and I won't
read the whole buffer. In this case, things gets corrupted for requests that
follow. Once I do read the whole buffer, things works correctly. I can
skipBytes in the size of (writerIndex - readerIndex) in case of an
exception, but then I wonder how does the built in ObjectDecoder handles
this case..., maybe I am missing something?
cheers,
shay.banon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100512/2bd798bd/attachment.html
More information about the netty-users
mailing list