genesluder / python-apns

A library for interacting with APNs using HTTP/2 and token-based authentication.
MIT License
90 stars 50 forks source link

force HTTP20Connection, allow for forcing of protocol (for python 2.7) #3

Closed d-ross closed 7 years ago

d-ross commented 7 years ago

I wanted to use this library (thank you for putting it together) in a Python 2.7 environment, but I was getting a ConnectionReset from hyper (http://gobiko.com/blog/connection-reset-error-hyper-debian-jessie/). However, in my case OpenSSL wasn't the culprit - it was along the lines of this hyper issue: https://github.com/Lukasa/hyper/issues/213

The fix was simply to force the protocol over to 'h2' (and use the HTTP20Connection class) - which seems OK here since APNs doesn't support anything else. Basically this is just exposing the force_proto hyper setting to your library.

genesluder commented 7 years ago

Glad you found it useful and thanks for the fix!

d-ross commented 7 years ago

No problem - btw everything running smooth on this env:

Ubuntu 14.04.1 LTS Python 2.7.6 OpenSSL 1.0.1f

The only head-scratcher was that this env couldn't read the .p8 you get from Apple. Turns out it just needed line breaks (http://disq.us/p/1ecxfqv).