Netty behavior when disconnecting a channel

Trustin Lee trustin at gmail.com
Mon Jan 3 22:15:53 EST 2011


Hi,

Netty will always read until there is nothing to read before disconnection.

Once Netty reads data and triggers messageReceoved event with it, Netty forgets about it and it is up to the pipeline to handle it, discard it, or store it somewhere for later use.  Usually, a decoder will store it for later use to deal with fragmentation.  If data is lost, there is high chance where it is stored but not consumed completely somewhere in your pipeline.

HTH

--
Trustin Lee - http://gleamynode.net/
Sent from a mobile device - please excuse the brevity.

On Dec 23, 2010, at 5:58 PM, Ric Klaren <rklaren at educator.eu> wrote:

> Hi,
> 
> We have been using netty for a while now and pretty much liking it.
> But we are running into a bit of trouble with the re-implementation of
> basically a sort of data stream forwarder.
> 
> What we are trying to accomplish:
> 
> Our main application does a request to a report generator with a
> correlation ID, prepares a receive buffer and registers the ID in a
> simple stream receiver (implemented in netty).
> The report generator does some startup checks, sends the response to
> the main application (stream coming/or some error like report file not
> found). Once the report is generating data it is sent to the main
> application with at the start the correlation ID (so we can direct the
> right data stream to the right web client). Once the generator is done
> it closes the stream (and once buffers are empty the socket).
> 
> E.g. we don't want to store intermediate files and we like to keep
> memory requirements pretty much fixed/low (the reports can be large
> and we are restrained to a 32 bit VM).
> 
> We basically have this working but during the building of integration
> tests for the whole I noticed that bytes probably left in the receive
> buffers are getting discarded once the report generator closes the
> socket. I got the feeling I'm missing something obvious.
> 
> During tinkering I got a few questions:
> 
> * Does Netty wait with sending the disconnected event untill the
> receive buffers (netty internal and network stack) are empty?
> * If a ChannelBuffer offered to a pipeline is not empty at the end of
> the pipeline those bytes and the ChannelBuffer are gone? Or is the
> Buffer offered to the pipeline untill it is empty? I made the latter
> assumption at some point but it does not seem to be the case?
> 
> Cheers,
> 
> Ric
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users



More information about the netty-users mailing list