I am trying to connect to a local running Restlet server with python, but the connection hangs endlessly (or disconnects if I set a timeout).
import urllib2 handle = urllib2.urlopen("http://localhost:8182/contact/123")
If I use curl from the shell to open the above URL, the results are returned quickly. If I use urllib2 to open another local service (e.g. Django web server on port 8000), urllib2 works fine.
I tried disabling the firewall (I do this on OS X). I tried changing localhost to 127.0.0.1. The logs from Restlet for connecting curl and urllib2 look the same away from the user agent.
My workaround would be to just call curl via subprocess , but I would better understand why this is not working.
Here's what my Restlet resource looks like:
public class ContactResource extends ServerResource { @Get public String represent() throws Exception { return "<contact details>"; }
Let me know if you want more info / code
java python curl urllib2 restlet
Dolan antenucci
source share