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@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/