无法使用 python 3.5 和 Hyper 向 APNS 发送 ALPN 请求
Cannot send ALPN request to APNS with python 3.5 and Hyper
我正在尝试使用 Hyper 在我的 Python REST 服务器上实施 APNS 服务。
由于 APNS 现在需要 HTTP/2 (ALPN) 协议,我无法从 Hyper 连接 get_response()
。它抛出以下错误。
Traceback (most recent call last):
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib64/python3.5/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/lib64/python3.5/dist-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 489, in dispatch
response = self.handle_exception(exc)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 449, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 486, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/lib/python3.5/dist-packages/rest_framework/decorators.py", line 52, in handler
return func(*args, **kwargs)
File "/opt/vr-inspire/apns/views.py", line 137, in apns
resp = conn.get_response()
File "/usr/lib/python3.5/dist-packages/hyper/common/connection.py", line 129, in get_response
return self._conn.get_response(*args, **kwargs)
File "/usr/lib/python3.5/dist-packages/hyper/http11/connection.py", line 203, in get_response
self._sock.fill()
File "/usr/lib/python3.5/dist-packages/hyper/common/bufsocket.py", line 169, in fill
raise ConnectionResetError()
ConnectionResetError
我做了一些研究,结果发现 ALPN 需要 OpenSSL 1.0.2。我参考 this 文章从源代码编译了 OpenSSL 1.0.2i 和 Python 3.5.1。
我用 import ssl print(ssl.OPENSSL_VERSION)
和 returns OpenSSL 1.0.2i 22 Sep 2016
检查了 ssl 版本。但是 ssl.HAS_ALPN
return False。
我正在使用 Amazon Linux,如何使用 ALPN 向 APNS 服务器发送请求?谢谢。
我尝试将 python 3.6.1 与 openssl 1.0.2k 一起使用,它可以正常工作。
我正在尝试使用 Hyper 在我的 Python REST 服务器上实施 APNS 服务。
由于 APNS 现在需要 HTTP/2 (ALPN) 协议,我无法从 Hyper 连接 get_response()
。它抛出以下错误。
Traceback (most recent call last):
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib64/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib64/python3.5/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/lib64/python3.5/dist-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 489, in dispatch
response = self.handle_exception(exc)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 449, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/lib/python3.5/dist-packages/rest_framework/views.py", line 486, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/lib/python3.5/dist-packages/rest_framework/decorators.py", line 52, in handler
return func(*args, **kwargs)
File "/opt/vr-inspire/apns/views.py", line 137, in apns
resp = conn.get_response()
File "/usr/lib/python3.5/dist-packages/hyper/common/connection.py", line 129, in get_response
return self._conn.get_response(*args, **kwargs)
File "/usr/lib/python3.5/dist-packages/hyper/http11/connection.py", line 203, in get_response
self._sock.fill()
File "/usr/lib/python3.5/dist-packages/hyper/common/bufsocket.py", line 169, in fill
raise ConnectionResetError()
ConnectionResetError
我做了一些研究,结果发现 ALPN 需要 OpenSSL 1.0.2。我参考 this 文章从源代码编译了 OpenSSL 1.0.2i 和 Python 3.5.1。
我用 import ssl print(ssl.OPENSSL_VERSION)
和 returns OpenSSL 1.0.2i 22 Sep 2016
检查了 ssl 版本。但是 ssl.HAS_ALPN
return False。
我正在使用 Amazon Linux,如何使用 ALPN 向 APNS 服务器发送请求?谢谢。
我尝试将 python 3.6.1 与 openssl 1.0.2k 一起使用,它可以正常工作。