To close or not to close in exceptionCaught (was: Re: How to make exceptions (like channel closed exceptions) reach the sending code.)
"Trustin Lee (이희승)"
trustin at gmail.com
Sun Jun 6 22:38:56 EDT 2010
Basic rule of thumb is like this: If you can recover from the exception
and continue communication, you don't need to close the connection.
Otherwise you should close it.
If the data in the socket buffer was read by Netty, it will be notified
with MessageEvent even if you called close().
HTH,
Trustin
王福强 wrote:
> Since there was such a topic before, I would like to post a similar question
> here, Hope you experts can help to clear my head.
>
> most of the sample code will close the channel in exceptionCaught() method,
> but I want to know what is the best practice with this?
> 1- if we catch exception in this method, what we do with it? throw out? or
> just logging? or we can do more with it? as I know, if I want to do more
> with the exception, maybe I have to refer to some larger scope object
> reference.
> 2- if I close the channel, when this action can influence the
> messageReceived() action, why i ask this is that I found even I have called
> the close() method of channel in exceptionCaught(), the messageReceived()
> keep receiving packets, can u explained this behavior for me? thanks in
> advance.
> btw. I use OioClientSocketChannelFactory and work as a client that connect
> to some server.
>
>
--
what we call human nature in actuality is human habit
http://gleamynode.net/
More information about the netty-users
mailing list