clipper
clipper

Reputation: 13

Inconsistent result when resolving names with Twisted Agent.request and names

Using Python Twisted framework, when I use:

twisted.names.client.getHostByName('some_domain')

I get the domain name resolved to an IP address.

But when I use

from twisted.web.client import Agent
agent = Agent(reactor)
agent.request(b'GET', 'http://some_domain', None)

I get this error Error received [Failure instance: Traceback (failure with no frames): <class 'ValueError'>: invalid hostname: some_domain ]

The some_domain only has A record, no AAAA if that helps. Also, these are communicating between 2 AWS ECS containers with some_domain sitting behind AWS service discovery endpoint. Using Python 3.8.6 docker image and Twisted 20.3.0

Any ideas what is happening or where to look at? Thanks

Upvotes: 1

Views: 112

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48335

This unfortunate exception does not mean that there was a problem resolving the name to an address. It means that the name itself was considered invalid and no attempt was even made to resolve it. The reason it is considered invalid is difficult to say without knowing what the real domain name is. some_domain is perfectly valid but I assume the real domain you're using is something else.

This is not to say your domain is invalid but you may have a problem in your representation of it or there may be a bug in Twisted that causes it to be considered invalid. Again, without knowing what it is, it's hard to say more.

Upvotes: 1

Related Questions