Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

<urlopen error (11001, 'getaddrinfo failed')>

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


opengis at hushmail

Sep 10, 2009, 9:22 AM

Post #1 of 3 (1062 views)
Permalink
<urlopen error (11001, 'getaddrinfo failed')>

Hello Python User,
I am using python in an openlayers application to access another
server on my network via javascript. The proxy script works fine
when the application runs in Apache HTTP Server, but I get a
"<urlopen error (11001, 'getaddrinfo failed')>" error after moving
the application to Tomcat. The tomcat cgi configuration tested
fine with a "hello world" python script. I then boiled my proxy
script down to the following:

#!c:/Program Files/Python25/python.exe -u

import urllib2
import cgi

fs = cgi.FieldStorage()
url = fs.getvalue('url', "http://www.openlayers.org")
try:
y = urllib2.urlopen(url)
print y.read()

except Exception, E:
print "Status: 500 Unexpected Error"
print "Content-Type: text/plain"
print
print "url: ", url
print
print "Some unexpected error occurred. Error text was:", E

This script produces the "<urlopen error (11001, 'getaddrinfo
failed')>". The openlayers homepage is expected. My environment
is Tomcat 6, Apache 2, Win XP, and Python 2.5. I have my local
firewall turned off. Proxy support is enabled, and working, in
Apache 2.0 (I get the error with Apache Server stopped). I seem to
be missing something to facilitate the communication between
python, my network and tomcat. Any direction or solution is
greatly appreciated.

Thank you,
Josh

--
http://mail.python.org/mailman/listinfo/python-list


chris at simplistix

Sep 11, 2009, 6:54 AM

Post #2 of 3 (1017 views)
Permalink
Re: <urlopen error (11001, 'getaddrinfo failed')> [In reply to]

opengis [at] hushmail wrote:
> fs = cgi.FieldStorage()
> url = fs.getvalue('url', "http://www.openlayers.org")
> try:

insert a "print url" here...

> y = urllib2.urlopen(url)
> print y.read()

> This script produces the "<urlopen error (11001, 'getaddrinfo
> failed')>".

This is a name lookup failing, whatever you're ending up with in url is
either incorrect or the dns config of the server it's pointing at is
incorrect...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


opengis at hushmail

Sep 11, 2009, 10:29 AM

Post #3 of 3 (1009 views)
Permalink
Re: <urlopen error (11001, 'getaddrinfo failed')> [In reply to]

Thank you for the response. I have been using
urllib2.urlopen("http://www.openlayers.org"), so I can rule out the
url being incorrect. Since my original question I can add the
following:

1. I am not using a proxy to connect to the internet
2. I added these lines to the script:
...
proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
...
I believe this tells python not to look for a proxy server.
3. I have added http://www.openlayers.org and its ip to my windows
hosts file
4. socket.gethostbyname produces the same 11001 error as
urllib2.urlopen

You are spot-on suggesting a dns issue. It seems like python
cannot resolve hostnames when it is running in Tomcat 6. Here is
my Tomcat cgi config from web.xml:

<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value>C:/Program Files/Python25/python.exe</param-value>
</init-param>
<init-param>
<param-name>passShellEnviroment</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>

The hostnames consistently resolve in Apache Server with the same
script, so I don't think my dns config is wrong. I don't have a
local firewall, but could my network firewall be blocking python
from takin care of business? Can anyone share their experience or
a link on running python in Tomcat?

thanks again,
josh

On Fri, 11 Sep 2009 08:54:20 -0500 Chris Withers
<chris [at] simplistix> wrote:
>opengis [at] hushmail wrote:
>> fs = cgi.FieldStorage()
>> url = fs.getvalue('url', "http://www.openlayers.org")
>> try:
>
>insert a "print url" here...
>
>> y = urllib2.urlopen(url)
>> print y.read()
>
>> This script produces the "<urlopen error (11001, 'getaddrinfo
>> failed')>".
>
>This is a name lookup failing, whatever you're ending up with in
>url is
>either incorrect or the dns config of the server it's pointing at
>is
>incorrect...
>
>Chris
>
>--
>Simplistix - Content Management, Batch Processing & Python
>Consulting
> - http://www.simplistix.co.uk

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.