[Twisted-Python] Re: How to detect dead client connections in twisted
adelagon at gmail.com
Tue Jun 3 04:09:34 EDT 2008
Problem solved! I digged through the twisted.internet source codes and found
def setTcpKeepAlive(self, enabled):
I modifying the simple twisted server:
from twisted.internet import protocol
from twisted.internet import reactor
print "Client Connected Detected!"
### enable keepalive
def connectionLost(self, reason):
print "Client Connection Lost!"
def dataReceived(self, data):
factory = protocol.Factory()
factory.protocol = EchoProtocol
Now the server is aware of keepalive timeouts now. Might as well use it in
my xmpp server. :)
On Tue, Jun 3, 2008 at 3:21 PM, Alvin Delagon <adelagon at gmail.com> wrote:
> Yes it supposed to be handled by the tcp_keepalive itself (as I assumed).
> The weird thing was that we had this configuration:
> Ubuntu Linux Server 2.6.15-26
> tcp_keepalive_time 7200
> tcp_keepalive_probes 9
> tcp_keepalive_intvl 75
> I have an XMPP client last sent a packet to the server at May 29 15:57:25
> telling that it will enter an idle state. On May 30 approx 08:00:00 I shut
> down my PC which hosts my XMPP client thus causing a half-opened state. The
> next day (17:41:11) while checking the logs, its still in half-opened state
> and my server still thinks that I'm online. It seems that tcp_keepalive
> kernel feature that's supposed to run every 2 hours didn't kick in.
> Alvin Delagon
> On Tue, Jun 3, 2008 at 2:42 PM, Gabriel Rossetti <mailing_lists at evotex.ch>
>> Alvin Delagon wrote:
>>> 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
>> Just a question, could setting the tcp keepalive feature on the server
>> side (not sure if that is possible), would that make the server detect that
>> the connection is dead/half-open?
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python