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

Kevin Horn kevin.horn at gmail.com
Fri Jan 20 14:06:51 EST 2012


On Thu, Jan 19, 2012 at 8:19 AM, Facundo Batista
<facundobatista at gmail.com>wrote:

> I have some code that uses a twisted.web.client.HTTPClientFactory.
>
> I've found that because some issues (firewall rules, not relevant to
> the problem), I experienced failures to connect.
>
> More specifically, I told it to connect to one particular address, and
> because of DNS load distribution, that address converted to several
> different IPs, and one of that IPs was not open, so it failed to
> connect with a TCPTimedOutError (code 110).
>
> When it failed to connect, it executed the "clientConnectionFailed"
> method of HTTPClientFactory, which receives a
> twisted.internet.tcp.Connector instance, and the reason of the
> failure.
>
> The question is: Is there a way, at that point (when
> clientConnectionFailed is called), to find out *to which IP* it failed
> to connect?
>
> Thank you very much!
>
> --
> .    Facundo
>
> Blog: http://www.taniquetil.com.ar/plog/
> PyAr: http://www.python.org/ar/
>

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)

Kevin Horn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20120120/d25d072f/attachment.htm 


More information about the Twisted-Python mailing list