I\'m running a Twisted server with the LineReceiver protocol. Sometimes clients will disconnect silently, so Twisted keeps the connection open. And because the server doesn\'t
You can schedule timed events using reactor.callLater
. Based on this, there's a helper for adding timeouts to protocols, twisted.protocols.policies.TimeoutMixin
.
Another approach is to use TCP keep-alives, which you can enable using the transport's setTcpKeepAlive
method.
And another approach is to use application-level keep-alives. Essentially send a ''noop'' once in a while. It doesn't need a response. If the connection has been lost, the extra data in the send buffer will cause the TCP stack to eventually notice.
See also the FAQ entry.