How to detect connection refused (tcp reset or icmp reject) and connection timeout

255 views
Skip to first unread message

Pierre

unread,
Oct 29, 2015, 4:15:16 AM10/29/15
to Netty discussions
Hi,

I'm using netty in client mode.

When I force error by connecting to a port which timeout I just have the event channelUnregistered after timeout, but no exception triggered.

When I connect to a port which refuse connection I just get channelUnregistered fired immediatly, but, no exception triggered.

How to get event for "connection refused" or "connection timeout" ? I expected to get them in exceptionCaught() of my ChannelHandler but it's not the case. I need to retrieve the specific reason of the connect failure.

Pierre

unread,
Nov 25, 2015, 8:33:37 AM11/25/15
to Netty discussions
nobody ?

Alex P

unread,
Nov 30, 2015, 7:14:25 AM11/30/15
to Netty discussions
Hello Pierre, 

Usually when you connect, you can make `syncUninterruptibly().channel()` on bootstrap/connect, whis will either give you a channel retrow an exception (from javadoc: "Waits for this future until it is done, and rethrows the cause of the failure if this future failed").

If you'd like to get notified on connection timeout, you have to use `IdleStateHandler` which would help you to implement something like heartbeats and ensure that channel is still alive.
Reply all
Reply to author
Forward
0 new messages