Page 1 of 1

Client recieving "connectionLost" message late?

Posted: 08 Jan 2009, 14:18
by tacroy
We are using SFS and openspace
We have some code that fires when the connection is lost it is in the

Code: Select all

smartFox.addEventListener( SFSEvent.onConnectionLost, onConnectionLost )
handler.

Most times it fires fine. After a few minutes of being idle it fires off the connectionLost message and we pop up a msg saying you are disconnected from idle.

However randomly it will NOT send the message from server when a client has been idle for some time. The client will still be disconnected from SFS and if they try to interact with the world (chat, change room, etc) it will not work, however it LOOKS like they are still logged in. A few minutes later it *realizes* that it is not connected and calls the "connectionLost" message and kicks them out.

I've not been able to tell a pattern and was hoping for a fix or some troubleshooting help.

Thank you.

Posted: 10 Jan 2009, 15:39
by Lapo
Unfortunately this problem is likely to be depending on a "bad disconnection" happening at TCP level. The Flash player is well known to have these problems which are more likely to appear with IE (at least this is what we usually see)

These "bad" disconnections have a tendency to happen when the client connection is problematic, very slow or lagged. A TCP disconnection has to be ackonwledged from both ends to take place and if this doesn't happen you're going see those weird behaviors.
Usually the underlying TCP implementation will recognize those "ghost connections" after a while and get rid of them.

Posted: 12 Jan 2009, 14:27
by tacroy
So is there a recommendation on how to deal with them? Is there a "test live connection" call or something that I can ping regularly to see if there connection is still alive? (or before each action)

Posted: 12 Jan 2009, 14:45
by Lapo
Nope, because at the Flash Player level the connection seems established while actually it is not.
By the way, this shouldn't be happening very frequently. If it does you should investigate in possible causes of the problem including firewall/router settings on the server end, lack of bandwidth etc...

A strategy to keep the client alive is to send a ping-pong type message from client to server and the other way around every n seconds. (30, 60 ore more)
If your "ping" doesn't receive a "pong" after a certain amount of time you should probably force a disconnection from client side (not guaranteed to work 100% as mentioned in the previous post, but it could help)

Posted: 13 Jan 2009, 12:47
by tacroy
Is there some standard code I can use for that PING PONG message?

Or is it just
Client call a serverside extension
Extension return a response
If client doesn't receive a response in a few seconds force disconnect
?

Posted: 13 Jan 2009, 16:39
by Lapo
That is exactly correct. You can send an extension request with name "ping" and no data (maybe using json or raw protocol) and the same goes from server side where you can send a response called "pong" and no data.