diff --git a/apns2/client.py b/apns2/client.py index 0947350..94cc89f 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -253,6 +253,11 @@ def connect(self) -> None: while retries < MAX_CONNECTION_RETRIES: # noinspection PyBroadException try: + if retries > 0: + # HTTP20Connection._sock might get stuck, this line closes the HTTP20Connection manually to reset it + # fully from the second retry onwards + self._connection.close() + self._connection.connect() logger.info('Connected to APNs') return