Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 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 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...