2015-04-22 3 views
3

Я пытаюсь использовать Flask-APNS, ранее я проверяю, что мой ck.pem (cert и ключ в одном файле) работает на php-сервере.flask apns - SysCallError: (-1, 'Неожиданный EOF')

Но каждый раз, когда я пытаюсь выполнить:

from apns import APNS 
#apns = APNS(app, cert_file='ZivingCert.pem', key_file='ZivingKey.pem',passphrase='mypassphrase') 
apns = APNS(app, cert_file='ck.pem', passphrase='mypassphrase') 
apns.send_message(tokens=['fad71c0b27416f055bfb1617c8db4e55d1b98b412443e68fba65cfe59748b81a'], alert='hi world', extra={}) 

Я получаю эту ошибку:

WARNING:apnsclient.backends.stdio:Failed to establish socket/SSL connection to ('gateway.sandbox.push.apple.com', 2195) 

No handlers could be found for logger "apnsclient.backends.stdio" 
    Traceback (most recent call last): 

     File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run 
     self.result = application(self.environ, self.start_response) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__ 
     return self.wsgi_app(environ, start_response) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app 
     response = self.make_response(self.handle_exception(e)) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 263, in error_router 
     return original_handler(e) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception 
     reraise(exc_type, exc_value, tb) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 260, in error_router 
     return self.handle_error(e) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app 
     response = self.full_dispatch_request() 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request 
     rv = self.handle_user_exception(e) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 263, in error_router 
     return original_handler(e) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception 
     reraise(exc_type, exc_value, tb) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 260, in error_router 
     return self.handle_error(e) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request 
     rv = self.dispatch_request() 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request 
     return self.view_functions[rule.endpoint](**req.view_args) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 431, in wrapper 
     resp = resource(*args, **kwargs) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_httpauth.py", line 60, in decorated 
     return f(*args, **kwargs) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask/views.py", line 84, in view 
     return self.dispatch_request(*args, **kwargs) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/flask_restful/__init__.py", line 521, in dispatch_request 
     resp = meth(*args, **kwargs) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/scheduler/ws/v1/schedulesapns.py", line 21, in get 
     apns.send_message(tokens=['fad71c0b27416f055bfb1617c8db4e55d1b98b412443e68fba65cfe59748b81a'], alert='hi world', extra={}) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/scheduler/apns/__init__.py", line 134, in send_message 
     res = srv.send(message) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/apns.py", line 90, in send 
     status = self._connection.send(message) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/transport.py", line 255, in send 
     with self: 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/transport.py", line 228, in __enter__ 
     self._open_connection() # can raise exception, bubblit up to the top 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/transport.py", line 519, in _open_connection 
     timeout=self.session.connect_timeout 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/backends/__init__.py", line 88, in get_cached_connection 
     return self.get_new_connection(address, certificate, timeout=timeout) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/backends/stdio.py", line 378, in get_new_connection 
     return self.connection_class(address, certificate, timeout=timeout) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/backends/stdio.py", line 142, in __init__ 
     self._open_connection(timeout) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/backends/stdio.py", line 153, in _open_connection 
     self._connect_and_handshake() 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/apnsclient/backends/stdio.py", line 188, in _connect_and_handshake 
     self._connection.do_handshake() 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1442, in do_handshake 
     self._raise_ssl_error(self._ssl, result) 
     File "/Users/Ricardo/Documents/python/openshift/scheduler_env/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1180, in _raise_ssl_error 
     raise SysCallError(-1, "Unexpected EOF") 
    SysCallError: (-1, 'Unexpected EOF') 
+1

Неожиданный EOF не похож на фактическую ошибку, но только следствие «Нет обработчиков может быть найдено для регистратора» apnsclient.backends.stdio ». Возможно, [это] (http://stackoverflow.com/a/346501/214577) поможет. – Oldskool

+0

Я обновляю сообщение об ошибке с помощью «ПРЕДУПРЕЖДЕНИЕ: apnsclient.backends.stdio: Не удалось установить соединение сокета/SSL к (« gateway.sandbox.push.apple.com », 2195)» – Ricardo

ответ

4

я, наконец, фиксированные благодаря регистрации сообщений.

Чтобы включить ведение журнала:

import logging 
logging.basicConfig() 

Чтобы исправить WARNING:apnsclient.backends.stdio:Failed to establish socket/SSL connection to ('gateway.sandbox.push.apple.com', 2195), вызванные проблемой безопасности с SSL версии 3.0 Push уведомление поддержки сервера Apple, удалить для SSL 3.0, так как в среду, 29 октября 2014 г.

def my_callback(key, reason): 
    print "my_callbaaaaaaack" 
    print str(key) 
    print str(reason) 

import OpenSSL 
OpenSSL.SSL.SSLv3_METHOD = OpenSSL.SSL.TLSv1_METHOD 
from apns import APNS 
apns = APNS(app, cert_file='ck.pem', passphrase='mypassphrase', failure_callback=my_callback) 
Смежные вопросы