While attempting to make an HTTP/2 request with hyper, I came across the following error:
>>> # Open a connection the APNS server >>> conn = HTTPConnection('api.development.push.apple.com:443') >>> # Send our request >>> conn.request( ... 'POST', ... path, ... body, ... headers=request_headers ... ) >>> resp = conn.get_response() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/srv/www/test/lib/python3.5/site-packages/hyper/common/connection.py", line 129, in get_response return self._conn.get_response(*args, **kwargs) File "/srv/www/test/lib/python3.5/site-packages/hyper/http11/connection.py", line 203, in get_response self._sock.fill() File "/srv/www/test/lib/python3.5/site-packages/hyper/common/bufsocket.py", line 169, in fill raise ConnectionResetError() ConnectionResetError
Note that hyper seems to be attempting a HTTP/1.1 request. It turns out that the problem lies in the version of OpenSSL in Debian Jessie.
Hyper needs ALPN to negotiate the HTTP/2 protocol. As of this writing stable Jessie is at OpenSSL < 1.0.2, but ALPN was introduced in 1.0.2.
The good news is that the supporting version is available in jessie-backports
Create /etc/apt/sources.list.d/jessie-backports.list with the line:
deb http://ftp.debian.org/debian jessie-backports main
Update apt and install OpenSSL
apt-get update apt-get install -t jessie-backports openssl
You'll also need to compile and install Python 3.5.
git clone --branch=3.5 --single-branch https://github.com/python/cpython.git cd cpython ./configure make sudo make altinstall
Create a virtual environment against the compiled version of python3.5
virtualenv --no-site-packages --distribute -p /usr/local/bin/python3.5 . source bin/activate
pip install -U setuptools
pip install hyper