Problem solved! I digged through the twisted.internet source codes and found this facility:<br><br>&nbsp;def setTcpKeepAlive(self, enabled):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, enabled)<br>
<br>I modifying the simple twisted server:<br><br>#!/usr/bin/python<br>from twisted.internet import protocol<br>from twisted.internet import reactor<br><br>class EchoProtocol(protocol.Protocol):<br><div id="1fr4" class="ArwC7c ckChnd">
&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass<br><br>&nbsp;&nbsp;&nbsp; def connectionMade(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Client Connected Detected!&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(255, 0, 0);">### enable keepalive</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.setTcpKeepAlive(1) </span><br>
<br>&nbsp;&nbsp;&nbsp; def connectionLost(self, reason):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Client Connection Lost!&quot;<br><br>&nbsp;&nbsp;&nbsp; def dataReceived(self, data):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.write(data)<br>
<br><br>factory = protocol.Factory()<br>factory.protocol = EchoProtocol<br>reactor.listenTCP(8000, factory)<br>reactor.run()</div><br>Now the server is aware of keepalive timeouts now. Might as well use it in my xmpp server. :)<br>
<br><br>---<br>Alvin Delagon<br><br><br><div class="gmail_quote">On Tue, Jun 3, 2008 at 3:21 PM, Alvin Delagon &lt;<a href="mailto:adelagon@gmail.com">adelagon@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yes it supposed to be handled by the tcp_keepalive itself (as I assumed). The weird thing was that we had this configuration:<br><br>Ubuntu Linux Server 2.6.15-26<br>tcp_keepalive_time 7200<br>tcp_keepalive_probes 9<br>tcp_keepalive_intvl 75<br>

<br>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&#39;m online. It seems that tcp_keepalive kernel feature that&#39;s supposed to run every 2 hours didn&#39;t kick in.<br>

<br>---<br><font color="#888888">Alvin Delagon</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Tue, Jun 3, 2008 at 2:42 PM, Gabriel Rossetti &lt;mailing_lists@evotex.ch&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><br>
Alvin Delagon wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I just recently discovered that it&#39;s a TCP half-open socket scenario that can be remedied by monitoring client heartbeats. This is not twisted related issue. Thanks anyway. :)<br>
<br>
Alvin Delagon<br>
<br>
</blockquote>
<br></div>
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?<br>
<br>
Gabriel<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br><br clear="all"><br></div></div><div><div></div><div class="Wj3C7c">-- <br><a href="http://www.alvinatorsplayground.blogspot.com/" target="_blank">http://www.alvinatorsplayground.blogspot.com/</a>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.alvinatorsplayground.blogspot.com/">http://www.alvinatorsplayground.blogspot.com/</a>