[Twisted-Python] Keeping a list of connected PB clients

Jean-Paul Calderone exarkun at divmod.com
Mon Nov 20 09:41:56 EST 2006

On Mon, 20 Nov 2006 09:19:43 -0500, Phil Christensen <phil at bubblehouse.org> wrote:
>On Nov 19, 2006, at 9:13 PM, Yi Qiang wrote:
>>On 11/19/06, Phil Christensen <phil at bubblehouse.org> wrote: On Nov  19, 
>>2006, at 7:00 PM, Yi Qiang wrote:
>> > There does not seem to be a corresponding clientConnectionLost
>> > method for the Factory class.  Any suggestions would be appreciated.
>>My approach to this was to put any post-connection cleanup in the
>>Avatar's "logout" method.
>>Will that method be called regardless of how the client disconnects  from 
>>the server?
>Yeah, in my experience the server *always* detects the connection  loss and 
>calls logout.
>Incidentally, this was with a standard reactor on a UNIXish system;  I'm 
>relatively sure this works this way on all platforms.

If there is traffic over a connection, a disconnect will always be noticed eventually (it might take a few minutes, though).

If a connection is idle, a disconnect can go unnoticed for a long time.  This
is just as much a problem with the cred "logout" method as using
clientConnectionLost (since one relies on the other, of course).

You can address this by using TCP keepalive or an application-level ping/pong
message every few minutes, to make sure there is traffic on the connection.

Of course your application may always keep the connection busy, so you may
not need to worry about this at all.


More information about the Twisted-Python mailing list