我有一个使用web.py的python服务器与Apple推送通知服务器进行通信,这些服务器经常遇到SSLEOFError。我试图处理这个错误,但我似乎无法在ssl模块或pyopenssl或_ssl中找到它。任何帮助处理此错误或可能防止它将不胜感激。这是堆栈跟踪:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/web/application.py", line 239, in process
return self.handle()
File "/usr/lib/python2.7/dist-packages/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/usr/lib/python2.7/dist-packages/web/application.py", line 420, in _delegate
return handle_class(cls)
File "/usr/lib/python2.7/dist-packages/web/application.py", line 396, in handle_class
return tocall(*args)
File "/home/ubuntu/mdm-server/server/API/api.py", line 189, in GET
COMMAND_QUEUE.get_queue(sql)
File "/home/ubuntu/mdm-server/server/queue.py", line 165, in get_queue
self.send_apns(row['udid'], sql)
File "/home/ubuntu/mdm-server/server/queue.py", line 219, in send_apns
except ssl.SSLEOFError:
AttributeError: 'module' object has no attribute 'SSLEOFError'
编辑:这里是没有错误处理错误的堆栈跟踪。我现在意识到我应该只处理超级班ssl.SSLERROR
而不是ssl.SSLEOFERROR
而我会尝试这样做,但是对于为什么会发生这种情况的任何见解将会非常感激。< / p>
Unexpected error: <class 'ssl.SSLError'>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/web/application.py", line 239, in process
return self.handle()
File "/usr/lib/python2.7/dist-packages/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/usr/lib/python2.7/dist-packages/web/application.py", line 420, in _delegate
return handle_class(cls)
File "/usr/lib/python2.7/dist-packages/web/application.py", line 396, in handle_class
return tocall(*args)
File "/home/ubuntu/mdm-server/server/API/api.py", line 189, in GET
COMMAND_QUEUE.get_queue(sql)
File "/home/ubuntu/mdm-server/server/queue.py", line 165, in get_queue
self.send_apns(row['udid'], sql)
File "/home/ubuntu/mdm-server/server/queue.py", line 216, in send_apns
wrapper.notify()
File "/usr/local/lib/python2.7/dist-packages/APNSWrapper-0.6.1-py2.7.egg/APNSWrapper/notifications.py", line 194, in notify
apnsConnection.connect(apnsHost, self.apnsPort)
File "/usr/local/lib/python2.7/dist-packages/APNSWrapper-0.6.1-py2.7.egg/APNSWrapper/connection.py", line 215, in connect
self.context().connect(host, port)
File "/usr/local/lib/python2.7/dist-packages/APNSWrapper-0.6.1-py2.7.egg/APNSWrapper/connection.py", line 161, in connect
self.connectionContext.connect((host, port))
File "/usr/lib/python2.7/ssl.py", line 433, in connect
self._real_connect(addr, False)
File "/usr/lib/python2.7/ssl.py", line 423, in _real_connect
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
Edit2:ssl.SSLError处理错误。
Edit3:我必须编辑APNSWrapper,以便在服务器设置部分的GitHub存储库中详细使用TLSv1。 Example iOS MDM Server
答案 0 :(得分:0)
好吧,想通了。当APNs服务器无法与目标手机通信时,APNSWrapper会抛出此错误。 (例如,手机已关闭或没有接收。)如果有其他人遇到此问题,则尝试/除了阻止ssl.SSLError
的阻止将处理此异常。如果是这种情况,暂时停止对APN的另一次调用可能是一个好主意。