2

I'm trying to use Python's liburl2 to access the Dreamhost API documented here: http://wiki.dreamhost.com/API

Here is my code:

request  = urllib2.Request('https://api.dreamhost.com/?key=<key>')
response = urllib2.urlopen(request)
page = response.read()
print(page)

This invariably fails with the error:

urllib2.URLError: <urlopen error [Errno 104] Connection reset by peer>

I'm absolutely stumped, because I can ping api.dreamhost.com just fine, and wget https://api.dreamhost.com/?key= works fine, too.

Any ideas?

sberry
  • 128,281
  • 18
  • 138
  • 165
loneboat
  • 2,845
  • 5
  • 28
  • 40
  • With the example code above, it works for me. I get an error message about requiring a command. – sberry Feb 20 '13 at 01:55
  • Your example works fine here. Are you behind a proxy? Also, you might want to generate a new API key after posting yours here. – alldayremix Feb 20 '13 at 02:03
  • FYI: I was able to list all of you dns records and see that I can delete or add new records. Change your key now... and delete this question. – sberry Feb 20 '13 at 02:04
  • It's been deleted. I'm such an idiot. 8-| That's what I get for trying to do web development with a cranky 1-year-old crying on my shoulder. Thanks for the heads' up. – loneboat Feb 20 '13 at 02:15
  • Hmmm, I'm not behind a proxy. Behind a router. But I can do wget and ping the host just fine. – loneboat Feb 20 '13 at 02:17
  • Am I right in thinking that since wget and ping can see the page/host just fine, that it's probably not a firewall/proxy issue? Or could there still be something set up wrong with the connection on my end (even though wget can see it fine)? – loneboat Feb 20 '13 at 03:15
  • I'm hitting this same issue with some node.js code that worked fine the last time I used it. I've since moved to a new home with a new internet connection (windstream) and firewall / router (Sagemcom F@st 1740n), so that sounds like a possible culprit. I'll let you know if I figure anything out. – Nathan Friedly Aug 13 '13 at 00:50
  • BTW, when I make the request with `wget`, it fails because the security certificate is invalid. When I retry with ` --no-check-certificate` it works. However, I tried the equivalent option in node.js and it didn't have any affect. – Nathan Friedly Aug 13 '13 at 17:19

1 Answers1

0

I know it's an old question, but I faced the same problem, and found the solution through two other questions.

This, that shows me the problem is with the handshake using SSLv3:

OpenSSL issues in Debian Wheezy

And this, that gives some possible solutions:

Python HTTPS requests (urllib2) to some sites fail on Ubuntu 12.04 without proxy

Community
  • 1
  • 1
DaneoShiga
  • 1,007
  • 8
  • 16