Changes between Version 23 and Version 24 of FrequentlyAskedQuestions


Ignore:
Timestamp:
01/12/09 01:26:34 (13 years ago)
Author:
Jean-Paul Calderone
Comment:

Why isn't my connectionLost method called?

Legend:

Unmodified
Added
Removed
Modified
  • FrequentlyAskedQuestions

    v23 v24  
    115115reactor.run()
    116116}}}
     117
     118=== Why isn't my `connectionLost` method called? ===
     119
     120TCP connections are closed in one of two ways.  They can either be closed "actively" - by one side of the connection sending a close message to the other side - or they can be closed by timeout - one side deciding that the other side has taken too long to respond and interpreting this to mean that the other side is no longer paying attention to the connection.  However, for the timeout case, it is important to understand that if an application is not sending data over the connection, '''there is no response''' to ''take too long'' so no timeout will ever occur.  This means that if a network error disrupts a connection but the application is not sending data over it, it's possible for `connectionLost` to never be called.  However, if the application is sending data over it, then the timeout will eventually expire.  TCP uses very large timeouts in order to account for very poor networks.  If you rely on TCP timeouts, expect as much as two hours (the precise amount is platform specific) to pass between when the disruption occurs and when `connectionLost` is called.  If this is too long, you may want to use an application-level ''keep alive'' mechanism to discover lost connections earlier.  This just involves sending simple messages back and forth over a connection.  If it ever takes longer than whatever amount of time you decide is appropriate for your application to receive a response to one of these messages, consider the connection lost.
    117121
    118122=== When I try to install my reactor, I get errors about a reactor already being installed. What gives? ===