Python's urllib2.urlopen() hanging with local connection to a Java Restlet server
Question: I'm trying to connect to a local running Restlet server from python, but the
connection hangs infinitely (or times out if I set a timeout).

    
    
    import urllib2
    handle = urllib2.urlopen("http://localhost:8182/contact/123") # hangs
    

If I use `curl` from a shell to open the above URL, the results return
quickly. If I use urllib2 to open a different local service (e.g. a Django web
server on port 8000), urllib2 works fine.

I've tried disabling firewall (I'm doing this on OS X). I've tried changing
localhost to 127.0.0.1. The logs from Restlet for both the curl and urllib2
connection appear the same aside from the user-agent.

My workaround would be to just call `curl` via `subprocess`, but I'd rather
understand why this is failing.

Here's how my Restlet Resource looks:

    
    
    public class ContactResource extends ServerResource {
    
      @Get
      public String represent() throws Exception {
        return "<contact details>";
      }
      //....
    }
    

Let me know if you want more info/code


Answer: I encountered the similar issues and ended up using the [Requests
package](http://docs.python-requests.org/en/latest/index.html).

