[Twisted-Python] Re: How to detect dead client connections in twisted

Alvin Delagon adelagon at gmail.com
Mon Jun 2 05:21:08 EDT 2008


I just recently discovered that it's a TCP half-open socket scenario that
can be remedied by monitoring client heartbeats. This is not twisted related
issue. Thanks anyway. :)

Alvin Delagon

On Mon, Jun 2, 2008 at 10:41 AM, Alvin Delagon <adelagon at gmail.com> wrote:

> I've been using xmlstream for quite sometime now and I noticed one such
> problem where my server doesn't detect clients that went to hardware
> shutdown without closing the socket. I also reproduced it using a simple
> twisted TCP server:
>
> #!/usr/bin/python
> from twisted.internet import protocol
> from twisted.internet import reactor
>
> class EchoProtocol(protocol.Protocol):
>     def __init__(self):
>         pass
>
>     def connectionMade(self):
>         print "Client Connected Detected!"
>
>     def connectionLost(self, reason):
>         print "Client Connection Lost!"
>
>     def dataReceived(self, data):
>         self.transport.write(data)
>
>
> factory = protocol.Factory()
> factory.protocol = EchoProtocol
> reactor.listenTCP(8000, factory)
> reactor.run()
>
> Using a different machine, telnet to the echo server and then shut down the
> computer (without exiting telnet). It seems that the connectionLost function
> doesn't get called. I even had an XMPP account appeared online on our XMPP
> server for almost three days even though I shut down the PC hosting my
> client. Should we implement a Hearbeat functionality? Thank you in advance!
>
> Alvin Delagon
>
> --
> http://www.alvinatorsplayground.blogspot.com/




-- 
http://www.alvinatorsplayground.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20080602/b23ac501/attachment.htm 


More information about the Twisted-Python mailing list