Exception on connect being caught by response handler

jgalyan jgalyan at adbrite.com
Mon Nov 22 14:59:20 EST 2010


I'm implementing ChannelFutureListener so I can avoid awaiting on
ChannelFutures and keep my application entirely asynchronous and event
driven.  When an exception happens during the connection attempt from my
client to a server, I expected the exception to be held by the ChannelFuture
so I could deal with it in operationComplete; instead, it's getting caught
by my response handler (the exception is Connection Refused, which I
wouldn't expect to be coming upstream to me).  Are my expectations wrong
here?

My use case is as follows:
I have a server that, as part of servicing a request from a client, sends a
request to a host in a cache cluster.  If the request to the host fails for
whatever reason, I want to mark that host down for a period of time so my
server doesn't try to contact that host again (hosts in the cluster go down
to reload their data periodically, by design.  At least two hosts in the
cluster will be up at any given time, but which two is not something I can
know in advance, for obvious reasons).  I would have expected the exception
caused by a host being down to be caught and held by the
ChannelFutureListener I attach to the future returned by connect(), rather
than being passed to the response handler's exceptionCaught method. (If the
connection fails, then a request doesn't get sent, so why would the response
handler be called here?) 

Do I need to implement exceptionCaught in the ChannelFutureListener
implementation or did I simply misunderstand the way the framework handles
exceptions?
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Exception-on-connect-being-caught-by-response-handler-tp5764119p5764119.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list