Opened 5 years ago
#5463 defect new
StringTransport and real transports inconsistent regarding use of getHost, getPeer in Protocol.connectionLost
|Reported by:||exarkun||Owned by:|
StringTransport happily returns host and peer information if its getHost and getPeer methods are called from a protocol's connectionLost method (even if it is called after StringTransport.loseConnection has been called, as should often be the case, but is not necessarily so).
However, real transports, such as the posixbase TCP transport, will raise an exception on this:
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 721, in getHost return address.IPv4Address('TCP', *self.socket.getsockname()) exceptions.AttributeError: 'Client' object has no attribute 'socket'
I think I prefer the StringTransport behavior. Being able to find out the connection endpoints, even after the connection has been lost, seems valuable.
These things should be consistent, though, with unit tests to verify it.