----- Original Message ----- > From: "Amit Saha" <as...@redhat.com> > To: "Twisted general discussion" <twisted-python@twistedmatrix.com> > Sent: Tuesday, December 10, 2013 11:59:27 AM > Subject: Re: [Twisted-Python] Queries about connecting to a XML-RPC server > over IPv6 > > > > ----- Original Message ----- > > From: "Phil Mayers" <p.may...@imperial.ac.uk> > > To: twisted-python@twistedmatrix.com > > Sent: Monday, December 9, 2013 7:33:17 PM > > Subject: Re: [Twisted-Python] Queries about connecting to a XML-RPC server > > over IPv6 > > > > On 09/12/13 05:28, Amit Saha wrote: > > > > > proxy = Proxy('http://localhost6:8000') > > > proxy.callRemote('my_proxy_method').addCallbacks(printValue, printError) > > > > > > > > > When I run it, i get "No route to host: 101, Network is unreachable". > > > > > > However, 'curl -6 localhost:8000' succeeds. What could be going on here? > > > > The IPv6 support in Twisted is very new - check your version even *has* > > it - and it's still a work in progress. You might find that you can't do > > this. I'd have to read the code to be sure and I don't have time right > > now, but my guess is that t.w.xmlrpc isn't "getaddrinfo"-ised so won't > > connect to IPv6 names. > > > > If your version of Twisted supports it, you could probably work around > > this by sub-classing Proxy and calling reactor.connectTCP('::1', 8000) > > to attach the protocol yourself. > > Thanks for your reply, Phil. So, I basically modified twisted/web/xmlrpc.py > so that > when it was calling connectTCP(), i substituted '::1' in place of self.host > and yes the method is called successfully. > > I will consider your other hints and see if there is an easy way to work > around this > in my particular use case.
I finally ended up doing this: (Sorry for the +) +class ProxyIPv6(xmlrpc.Proxy): + + def __init__(self, url, **kwargs): + + xmlrpc.Proxy.__init__(self, url, kwargs) + # resolve the LC's host/port to IPv6 address + # and overrise self.host + retries = 0 + while retries < 5: + try: + self.host = socket.getaddrinfo(self.host, self.port, + socket.AF_INET6, 0, socket.SOL_TCP)[0][4][0] + except: + # IPv6 look up failed + log.debug('Failed to look up IPv6 address for LC. Sleeping for 5s') + time.sleep(5) + retries += 1 + else: + log.info('Resolved IPv6 address of the LC.') + break I have the retry loop since I saw that the IPv6 name resolution was failing once, but never happened after that. The particular use case I am currently applying this is in a daemon process which starts on boot on a IPv4 and IPv6 system. Then I disable IPv4 and the communication with the XML-RPC proxy server happens only over IPv6. Thanks for the pointers earlier. -Amit. -- Amit Saha <http://echorand.me> _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python