Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
571 views
in Technique[技术] by (71.8m points)

python - Cannot fetch URLs from GAE local environment

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...