Blocking behavior differs in NIO client versus server

Alex Wang alex.wang06 at gmail.com
Tue Aug 3 21:42:10 EDT 2010


I implmented an NIO client and a server both use a subclass of
SimpleChannelHandler in the channel pipeline.  The handler is designed to
handle a synchronous protocol, and as such, the writeRequested() blocks (via
a BlockingQueue) and only returns when an ACK has been received thru
messageReceived().  This works fine in the client in that ACKs and other
messages continue to arrive and come up through the channel while
writeRequested() blocks, thus successfully removing the block as intended.  

However, when the same handler is used in a NIO server, the blocking
writeRequested() seems to lock the handler object and stops both incoming
and outgoing ACKs and messages, causing the blocking statement to time out. 
(I know this may not be a good way to handle a synchronous protocol, and I
have a couple of ideas after reading the "handshake" example. Any comments
will be greatly appreciated.)  But my question is why this works for the
client but not for the server?  By the way, I tried inserting an
ExecutionHandler before the handler in question, but that did not change the
server's behavior, i.e. incoming ACK got through the lower-level decoder at
the server channel, but the ACK did not get processed until after the
blocking statement times out.

Any help is highly appreciated!

Thanks,
Alex

-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Blocking-behavior-differs-in-NIO-client-versus-server-tp5370857p5370857.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list