Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can netty reliably detect channel close/disconnect?

Tags:

netty

specifically i am interested in the case where the other end of the channel dies unexpectedly (eg the process gets killed). it seems that netty does not reliably fire a channel closed/disconnect event, sometimes it does and sometimes it does not. it also does not necessarily throw a SocketException for connection reset.

for what it's worth, i have also tried writing to the channel but this also continues to work without throwing exceptions or firing any other events.

i am testing this on windows, with netty 3.3.0.Final, if that makes any difference.

like image 584
Christopher Ng Avatar asked Apr 03 '12 06:04

Christopher Ng


1 Answers

If a channel disconnects without sending close there is no way to detect it. Usually the best way to detect a disconnect if needed is to periodically send heartbeat events over the channel ever x seconds. Using IdleStateHandler, if you don't receive the heartbeat after the heartbeat + a delta you force disconnect the channel.

like image 165
Josh Wilson Avatar answered Oct 13 '22 04:10

Josh Wilson