[Twisted-Python] connectionLost not always getting called?
rob at 185vfx.com
Sun Jan 11 18:55:03 EST 2009
I've implemented a twisted server using the basic.lineReceiver class. The
client is a socket based client implemented in flash and the connections are
long-lived (minutes or hours). To handle cleaning up the players when they
disconnect, I'm using the connectionLost function in my player class. 99%
of the time, things work as expected.
However in rare cases, connectionLost is not getting called when the
flash-based client disappears. Even completely quitting the client's
web-browser does not always trigger a connectionLost call. I tracked down
one specific instance yesterday where the server thought the client was
still connected even though the client had been gone for 30+ minutes--but
after a few hours the server noticed that the client was gone and then
connectionLost was called like normal. That made me think that it might be
a problem on the server side and maybe not client related.
I'm starting on a workaround now where the client will issue a "PING" every
30 seconds and the server will use the ping information to manually trigger
loseConnection when needed. Are there a better workarounds for this, better
practices or some error checking I can do to avoid these intermidant laggy
Thanks in advance.
P.S. I've found twisted to have incredible performance compared to
everything else we've tried. If you're interested you can see the client at
http://www.guessasketch.com/ . I'm happy to post server code excerpts if it
would be helpful.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python