无法从GAE本地环境中获取网址 [英] Cannot fetch URLs from GAE local environment

查看:170
本文介绍了无法从GAE本地环境中获取网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 错误:

我试图在Google应用引擎中使用urllib2获取网址时出现以下错误:连接到服务器时发生错误:无法获取URL:http://www.google.com错误:[Errno 10106] getaddrinfo失败

这是调用urllib2开放读取方法的代码:

  def get(self) :
self.write(urllib2.urlopen(http://www.google.com).read())
self.render_index()



没什么特别的,只需要调用主要处理函数库中的库来获取获取的文本。



<我的电脑正确解析DNS。



从谷歌服务器运行的部署代码按照预期工作,这与我的本地环境有关,但我可以使用我的本地环境无法找到它是什么。



我也尝试使用gae中的urlfetch获得类似的结果(getaddrinfo失败)



在使用urllib2库之前的几天,我切换到Google DNS,但切换回ISP提供的DNS也无法使用。


$ b 编辑:当调用函数使用获取URL的IP地址:

  self.write(urllib2.urlopen(http://173.194.42.34 ).read())


解决方案

我很确定您的DNS解析器无法解析主机名。我假设你的操作系统或安全软件禁止devserver创建出站连接。另一种可能是您的操作系统上的主机文件中有无效的条目。



另外,还有很多类似的问题可以帮助你。


I'm getting the following error when trying to fetch an URL with urllib2 in the google app engine:

error: An error occured while connecting to the server: Unable to fetch URL: http://www.google.com Error: [Errno 10106] getaddrinfo failed

This is the code calling the urllib2 open read methods:

def get(self):
        self.write(urllib2.urlopen("http://www.google.com").read())
        self.render_index()

Nothing fancy, just a call to the library inside the main handler to ouptut the fetched text.

My PC resolves DNS correctly. I can use the urllib2 library from the python interpeter, fetching URLs successfully.

The deployed code running from the google servers work as intended, it's something with my local environment but I can't find what is it.

I also tried using urlfetch from gae with similar results (same getaddrinfo failed)

I switched to Google DNS some days before working with the urllib2 library but switching back to ISP provided DNS didn't work either.

EDIT: When calling the function with an IP address the URL is fetched:

self.write(urllib2.urlopen("http://173.194.42.34").read())

Thanks in advance!

解决方案

I'm fairly certain that your DNS resolver fails to resolve the hostname. I assume that your OS, or security software prohibits the devserver from creating outbound connection. Another possibility would be that you have invalid entry in your hosts file on your operating system.

Also, there are many similar questions which could help you.

这篇关于无法从GAE本地环境中获取网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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