[Twisted-Python] Finding out the IP which it failed to connect

Glyph Lefkowitz glyph at twistedmatrix.com
Sun Jan 22 16:30:31 EST 2012

On Jan 20, 2012, at 10:02 PM, Itamar Turner-Trauring wrote:

> On 01/20/2012 02:23 PM, Facundo Batista wrote:
>> On Fri, Jan 20, 2012 at 4:06 PM, Kevin Horn<kevin.horn at gmail.com>  wrote:
>>> twisted.internet.tcp.Connector has a getDestination() method, which should
>>> return an address object.
>>> Have you tried that? (I haven't, but it looks like the right thing)
>> It returns the name used, not the IP.
> That seems... wrong. Perhaps enshrined by prior existence, but wrong 
> nonetheless - it's an IPv4Address, it should have an IP. Could you file 
> a ticket?

See also <http://twistedmatrix.com/trac/ticket/3059>.

I thought this might be the same thing, but I guess it isn't.  At any rate the new ticket should reference this old one, since this is apparently an easy mistake to make.

Arguably this interface is kind of broken though: it's synchronous, but hostname resolution may not have completed yet.  Also hostname resolution may return a different address on subsequent reconnects, so there's no single destination that a hostname-based connector could be said to be connecting to.

All in all, just another reason to move to Endpoint-based client connections and ignore the Connector layer of the API in applications...


More information about the Twisted-Python mailing list