[Twisted-Python] connectionLost never reached after calling loseConnection: stuck in CLOSE_WAIT forever

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Oct 18 12:25:07 EDT 2010

On 03:21 pm, ste at demaledetti.net wrote:
>Hello Jean-Paul, thanks for looking into this.
>>>What did make a difference was to comment this line, the problem
>>>never happens without it:
>>>to.transport.registerProducer(_from.transport, True)
>>This suggests that your problem is that you don't unregister the
>>produce.  The connection can never be closed as long as a producer is
>>registered.  Does your code ever unregister this producer?
>I am 100% sure that I unregister the producer from the transport
>right before I call loseConnection on that transport (see code
>snippet in my original post). Even using reactor.callLater for
>calling loseConnection asynchronously after the producer has been
>unregistered didn't help.

Okay.  Then we're back to Glyph's idea, which is that there really is a 
bug to fix. :)
>Moreover, if it was just a problem of my code not unregistering the
>producer then this wouldn't explain why registering the producer as
>non-streaming fixes the issue. It also wouldn't explain why does
>this happen only in particular conditions and not always (even if I
>managed to reproduce it reliably, I still have to debug the exact
>external conditions that trigger it).

Hopefully this will turn into a simple example which can reliably 
reproduce the problem for everyone. :)
>As a side note, for once what you wrote is not 200% exact ;) because
>the connection is always closed properly if it's the peer closing it
>first, even if the producer is still registered in that case. (Maybe
>Twisted unregisters the producer by itself when this happens?)

Thanks for that clarification.


More information about the Twisted-Python mailing list