[xSocket-develop] send timeouts
Status: Inactive
Brought to you by:
grro
|
From: Phil J. <li...@ph...> - 2009-07-02 13:19:27
|
Hi, I've recently developed a back-end server for a customer's Flash game, and have been using xSocket with great success. You guys are doing a brilliant job, thank you! One thing I'm not entirely clear about is how to deal with dropped connections. If the connection is explicitly closed, there is no issue, the onDisconnect() handler function is called and I can clean up. I'm aware that there's no way to tell whether a TCP connection is live other than by writing data to it, so that's exactly what I do. I've set up an IdleTimeout handler to kick in after 1 minute of inactivity, which sends a 'ping' and resets the idle timeout. I've also discovered the org.xsocket.connection.sendFlushTimeoutMillis property, which I am currently not setting, and therefore using the 1-minute default. I was under the impression that with such a setup, my connection should be disconnected after a maximum of 2 minutes if I, for example, unplug the network cable of the client. (1 minute idle -> ping -> give up trying to send after 1 minute) That doesn't seem to be happening, however, it's taking somewhat longer. I've been looking at the traffic using Wireshark, and it seems that it doesn't even bother to retry pinging, probably because disconnecting the cable typically yields a "Destination Host Unreachable" from somewhere in the network stack, which is not an error that usually warrants a retry. Yet I don't seem to get any sort of event from xSocket for this for a long time. When I plug the cable back in, onDisconnect() fires very quickly, or the backlog of data gets through if the client hasn't given up; it seems that the send timeout isn't kicking in. Is there something I've missed? Do I need to use write completion handlers? I've avoided them so far due to the extra complexity. My setup uses xSocket 2.5.2 (2.5 until recently; same problem) in a near-default setup: autoflush is on, flush mode is sync. I'm quite sure I'm not getting any events that I'm not handling or that I'm handling incorrectly. Thanks and best regards, phil |