httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.37k stars 3.67k forks source link

ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer')) #351

Closed matiaskorhonen closed 9 years ago

matiaskorhonen commented 9 years ago

I've having some issues trying to use HTTPie with https://matiaskorhonen.fi, which is confusing since the site work fine in every browser I've tried and with curl. HTTPie on the other hand gives a Connection reset by peer error:

~ » curl -I https://matiaskorhonen.fi
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 06 May 2015 18:41:13 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 7417
Connection: keep-alive
Last-Modified: Tue, 05 May 2015 19:25:22 GMT
Vary: Accept-Encoding
Alternate-Protocol: 443:npn-spdy/2

~ » http --verbose HEAD https://matiaskorhonen.fi

http: error: ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))
~ » http --version
0.9.2
~ »

Using --verify=no doesn't help either. The server uses SNI TLS, might that be the issue?

jkbrzt commented 9 years ago

Yes, this seems to be related to SNI. You can either upgrade to Python 2.7.9 or 3.4, or manually install some dependencies, if you are stuck with an older Python version:

https://github.com/jakubroztocil/httpie#sni-server-name-indication

$ python --version
Python 2.7.9
$ http --verify=no --verbose HEAD https://matiaskorhonen.fi
HEAD / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: matiaskorhonen.fi
User-Agent: HTTPie/1.0.0-dev
HTTP/1.1 200 OK
Alternate-Protocol: 443:npn-spdy/2
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Wed, 06 May 2015 21:17:32 GMT
Last-Modified: Tue, 05 May 2015 19:25:22 GMT
Server: nginx
Vary: Accept-Encoding
matiaskorhonen commented 9 years ago

I got it to work with Python 3.

Cheers.

kyteague commented 8 years ago

I get this issue as well, using python 2.7.11 under OSX. I tried both pip and brew versions.

The equivalent curl command has no issue.

httpie version 0.9.3

jkbrzt commented 8 years ago

@kyteague is it a public URL?

kyteague commented 8 years ago

@jkbrzt no, unfortunately it's a private API.

If it's helpful -- the server uses nginx (https -- no spdy) using the following settings: ssl_protocols TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m;

This reverse proxies to a webservice written in Go.

jkbrzt commented 8 years ago

@kyteague Not sure what the issue is yet, but I'm only able to reproduce it on Python 2.7.10. It works fine on Python 2.7.11. I think you're on Python 2.7.10, too.

kyteague commented 8 years ago

I found the issue.

The http script hardcodes #!/usr/bin/python instead of the canonical #!/usr/bin/env python

This caused python 2.7.10 (from OSX) to be used instead of 2.7.11 (my default python from brew). 2.7.10 has the connection issue, while 2.7.11 does not.

This should definitely be patched as the latter #!/usr/bin/env python more accurately describes the location of the system python executable.

jkbrzt commented 8 years ago

@kyteague Yeah, the formula currently uses the system Python 2.7 which has some issues. I'm now testing a Python3-based formula which I'm considering for the next release to avoid issues like that. Feel free to give it a try:

$ brew install https://gist.githubusercontent.com/jkbrzt/e59a0cde6ae6f59f2182/raw/httpie.rb
tunix commented 8 years ago

@jkbrzt works as expected! thanks!

janhenriko commented 7 years ago

Installed httpie-ntlm with Python3, and that worked (on my MacOSX)

sudo python3 setup.py install

duginivijay commented 6 years ago

@jakubroztocil I tried the one you suggested but it has thrown the below error. VJ:audit vijay.dugini$ brew install https://gist.githubusercontent.com/jkbrzt/e59a0cde6ae6f59f2182/raw/httpie.rb

curl: (22) The requested URL returned error: 404 Not Found Error: Failure while executing: /usr/bin/curl --show-error --user-agent Homebrew/1.3.2\ (Macintosh;\ Intel\ Mac\ OS\ X\ 10.12.6)\ curl/7.54.0 --fail --progress-bar --location --remote-time --continue-at - --output /Users/vijay.dugini/Library/Caches/Homebrew/Formula/httpie.rb https://gist.githubusercontent.com/jkbrzt/e59a0cde6ae6f59f2182/raw/httpie.rb

jkbrzt commented 6 years ago

@duginivijay the Python 3 based formula is available directly from Homebrew (brew install httpie).

duginivijay commented 6 years ago

Ignore my post mate. I had multiple version of pythons in my machine due to which it wasn't able to pick the right one and was throwing error. Posting this thinking it may be helpful for someone.