From d3d75d1073ef259b45bdefb293ef33a554462bef Mon Sep 17 00:00:00 2001 From: Pavel Valach Date: Wed, 13 Dec 2017 15:19:17 +0100 Subject: [PATCH] client.connect(): after error, close the connection Otherwise, the next self._connection.connect() call will not try again. In fact, it will do nothing. It won't raise the exception again. Therefore, closing the connection before retrying is mandatory. --- apns2/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apns2/client.py b/apns2/client.py index f71c882..a44cbbf 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -183,6 +183,8 @@ class APNsClient(object): logger.info('Connected to APNs') return except Exception: # pylint: disable=broad-except + # close the connnection, otherwise next connect() call would do nothing + self._connection.close() retries += 1 logger.exception('Failed connecting to APNs (attempt %s of %s)', retries, MAX_CONNECTION_RETRIES)