Hi,
On Wed, 07 Jul 2010 14:16:25 +0200, Emmanuel Lecharny <[email protected]> wrote: > There is no way to detect a connection failure. The connection is opened > or closed, but you will know only after having successfully sent > something to the client. What about TCP KeepAlive? That IS checking the connection automatically. The only problem with this is: You don't know WHEN the OS will send a keep-alive-message to check the connection. It can be within seconds (unlikely), several minutes (more likely) or even hours ... (or maybe never?) It is possible to change the keep-alive interval, but this then counts for all socket connections the OS manages ... :-( A maybe useful hint: http://mindprod.com/jgloss/socket.html#DISCONNECT I don't use transactions. But I also wanted to know asap when the connection dies. So I created my own keepl-alive check: * As long as client and server and sending data to each other, the check happens when sending this data. If sending fails, the connection is broken * If client and server fall into IDLE (mina's session idle thing), then my communicationlayer on top of MINA sends ping-pong packages: If a pong has not been received xx sec after a ping is sent, the connection is broken. For me this has the positive sideeffect, that a "blocking" remote (dealocked?!) is detected as well. br, Alex
