Reconnect on Exception?

이희승 (Trustin Lee) trustin at gmail.com
Thu Sep 10 01:45:37 EDT 2009


Hi Bantai,

I've just added the 'Uptime' client example which demonstrates how to
implement reliable reconnection in Netty:

http://fisheye.jboss.org/browse/Netty/trunk/src/main/java/org/jboss/netty/example/uptime

You could start from this example and add some variation to this
example to customize the reconnection strategy.

Let me know if you think the example needs more explanation.

HTH,
Trustin

On Thu, 3 Sep 2009 03:42:03 +0900 (KST)
bantai <superman at bantai.com> wrote:
> 
> Hi,
> 
> The search function is not working for me so apologies if this has
> been asked and answered in the past but I'm looking for an example of
> how to best implement a reconnect feature.
> 
> I currently have a client and server passing object to each other but
> if I restart the server the client dies and I have to restart this as
> well. I've seen that I should implement the exceptionCaught method in
> the ClientHandler but am unsure of how to best try and reconnect with
> the server once an exception is caught.
> 
> So far since this is still in early development this is the only
> instance I've seen where I am unable to continue sending objects but
> there may be other times I need to reconnect (Channel could be down?)
> so I'm wondering if I could achieve something like a reconnect
> mechanism using a ChannelFutureListener since I can see when the
> Channel is closed but I've not found a way to reconnect with the
> Objects that are passed to me in that method.
> 
> Thanks for any help



-- 
Trustin Lee, http://gleamynode.net/


More information about the netty-users mailing list