使用Google App Engine套接字进行DNS查询 [英] DNS query using Google App Engine socket

查看:178
本文介绍了使用Google App Engine套接字进行DNS查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google App Engine的新套接字支持来执行一些DNS查询。我正在使用 dnspython 来执行查询,代码在GAE之外工作正常。

I'm trying to use the new socket support for Google App Engine in order to perform some DNS queries. I'm using dnspython to perform the query, and the code works fine outside 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中运行时,我收到以下错误:

When I run in GAE I get the following error:

  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在时间限制内没有返回答案时,由dnspython引发。我已经将timelimit提高到60秒,DnsQuery是一项任务,但仍然有相同的错误。

Which is raised by dnspython when no answer is returned within the time limit. I've raised the timelimit to 60 seconds, and DnsQuery is a task, but still getting the same error.

Google App Engine套接字实现有什么限制,阻止执行DNS请求?

Is there any limitation in Google App Engine socket implementation, which prevents the execution of DNS requests ?

推荐答案

这是一个错误,将尽快解决。

This is a bug and will be fixed ASAP.

作为一种解决方法,将source =''参数传递给dns.resolver.query。

As a workaround, pass in the source='' argument to dns.resolver.query.

tcp = True不是必需的。

tcp=True is not necessary.

这篇关于使用Google App Engine套接字进行DNS查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆