djacobs / PyAPNs

Python library for interacting with the Apple Push Notification service (APNs)
http://pypi.python.org/pypi/apns/
MIT License
1.22k stars 377 forks source link

Connection reset by peer #130

Closed bulv1ne closed 8 years ago

bulv1ne commented 8 years ago

I don't know if this is an issue of PyAPNs, but I don't know where else to ask. It worked before but doesn't anymore.

Since about 1 week ago our push notifications aren't getting through. I tried to google for "Connection reset by peer" but didn't get any answers that could lead to a solution.

2015-08-18 14:10:21,380 ERROR fus.push push_user (65) [Errno 104] Connection reset by peer
Traceback (most recent call last):
  File "./fus/push.py", line 62, in push_user
    push_ios(message, token.token, section, badge.counter, url, data)
  File "./fus/push.py", line 38, in push_ios
    apns.gateway_server.send_notification(token, payload)
  File "/home/admin/venv_kb/local/lib/python2.7/site-packages/apns.py", line 544, in send_notification
    self.write(self._get_notification(token_hex, payload))
  File "/home/admin/venv_kb/local/lib/python2.7/site-packages/apns.py", line 273, in write
    return self._connection().write(string)
  File "/home/admin/venv_kb/local/lib/python2.7/site-packages/apns.py", line 254, in _connection
    self._connect()
  File "/home/admin/venv_kb/local/lib/python2.7/site-packages/apns.py", line 230, in _connect
    self._ssl = wrap_socket(self._socket, self.key_file, self.cert_file)
  File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 143, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
    self._sslobj.do_handshake()
error: [Errno 104] Connection reset by peer
bulv1ne commented 8 years ago

Yes sorry, forgot to reply. The issue was that the certificate got for some reason removed from Apple's website. So renewing the certificate solved the issue. Do you think it is possible to raise a different exception when that happens, or is it difficult to know when the certificate is invalid?