ConnectionResetError with Hyper on Debian Jessie

While attempting to make an HTTP/2 request with hyper, I came across the following error:

>>> # Open a connection the APNS server
>>> conn = HTTPConnection('')
>>> # 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/", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/srv/www/test/lib/python3.5/site-packages/hyper/http11/", line 203, in get_response
  File "/srv/www/test/lib/python3.5/site-packages/hyper/common/", line 169, in fill
    raise 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

Upgrade OpenSSL

Create /etc/apt/sources.list.d/jessie-backports.list with the line:

deb jessie-backports main

Update apt and install OpenSSL

apt-get update
apt-get install -t jessie-backports openssl

Install Python 3.5

You'll also need to compile and install Python 3.5.

git clone --branch=3.5 --single-branch
cd cpython
sudo make altinstall

Install Hyper Against Python 3.5

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

Update setuptools

pip install -U setuptools

Install hyper

pip install hyper