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

Phil Christensen phil at bubblehouse.org
Mon Nov 20 13:26:40 MST 2006


On Nov 20, 2006, at 9:41 AM, Jean-Paul Calderone wrote:
> On Mon, 20 Nov 2006 09:19:43 -0500, Phil Christensen  
> <phil at bubblehouse.org> wrote:
>> 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.

Yeah, just  another anecdote w.r.t. JP's point here...

While I found that the server was quick to notice disconnects, my  
client -- which is more of a passive participant, primarily receiving  
messages from the server -- would not notice the server disappearing  
until another outgoing message was sent (or attempted to be sent).

I found implementing a noop keepalive took care of that.

JP, could you elaborate on your comment about idle connections? Is  
the PB server supposed to disconnect idle connections after some  
period of time? If so, I'd definitely like to make sure this doesn't  
happen just because someone isn't paying attention to a client in the  
background.

Thanks,

-phil




More information about the Twisted-Python mailing list