Closed ryanwang520 closed 6 years ago
What about APNsClient.connect()
?
The docstring says:
Establish a connection to APNs. If already connected, the function does nothing. If the connection fails, the function retries up to MAX_CONNECTION_RETRIES times.
This just won't work, the APNsClient.connect
method just calls the corresponding connect
method from hyper
, which does nothing if the connection is already established. you can just refer to the code from the link below.
https://github.com/Lukasa/hyper/blob/development/hyper/http20/connection.py#L344
So what`s the best solution for that issue.
Hi! It seems that apple will disconnect the socket if the apns client does not send any message to the apns server for a while(maybe several hours),and a
ConnectionResetError
would be raised from the underlyinghyper
package when you send message using the remotely closed socket. To handle this, I just hack it like the code below, which I don't think is an elegant way.There may exist a good way to solve the connection reset problem just in the
pyapns2
package,any ideas?
Thanks.