我正在尝试使用对 Google App Engine 的新套接字支持来执行一些 DNS 查询。我正在使用dnspython执行查询,并且代码在 GAE 之外运行良好。
代码如下:
class DnsQuery(webapp2.RequestHandler):
def get(self):
domain = self.request.get('domain')
logging.info("Test Query for "+domain)
answers = dns.resolver.query(domain, 'TXT', tcp=True)
logging.info("DNS OK")
for rdata in answers:
rc = str(rdata.exchange).lower()
logging.info("Record "+rc)
当我在 GAE 中运行时,出现以下错误:
File "/base/data/home/apps/s~/one.366576281491296772/main.py", line 37, in post
return self.get()
File "/base/data/home/apps/s~/one.366576281491296772/main.py", line 41, in get
answers = dns.resolver.query(domain, 'TXT', tcp=True)
File "/base/data/home/apps/s~/one.366576281491296772/dns/resolver.py", line 976, in query
raise_on_no_answer, source_port)
File "/base/data/home/apps/s~/one.366576281491296772/dns/resolver.py", line 821, in query
timeout = self._compute_timeout(start)
File "/base/data/home/apps/s~/one.366576281491296772/dns/resolver.py", line 735, in _compute_timeout
raise Timeout
当在时限内没有返回答案时,由 dnspython 引发。我已将时间限制提高到 60 秒,并且 DnsQuery 是一项任务,但仍然遇到相同的错误。
Google App Engine 套接字实现是否有任何限制,会阻止 DNS 请求的执行?