Skip to content

Fix APNs P8 HTTP2 error recovery #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

SixiS
Copy link
Contributor

@SixiS SixiS commented Apr 7, 2025

Original pull request: #723

Rebased off master and added a couple tests.
I'm not sure how best to interact with the original PR, so just cherry-picked in the original commits and made a new branch + pr.
Let me know if there would be a better way to do it.

Original PR Description:
Currently RPush uses faulty logic when determining if a notification should be retried. It only recognizes certain responses from APNs as needing a retry. Which means that any failure to actually deliver the notification will result in the notification being marked as failed.

Clearly, we should retry the notification unless - and until - we receive a response from APNs with a permanent failure code, or the notification reaches its maximum number of retries.

It is very common to receive Errno::ECONNRESET: Connection reset by peer errors from the APNs connection, and this issue has not been resolved in RPush. See #607. This error occurs because Apple closes the connection on their end after some period of inactivity. It's also common to receive OpenSSL::SSL::SSLError errors from the HTTP2 socket.

When an error occurs in the NetHttp2 client, it calls the error callback registered in create_http2_client and swallows the error. This means that the Delivery class never sees it and cannot handle it. So the notification remains in the processing state indefinitely. The threads which NetHttp2 create have abort_on_exception set to true, so we cannot
raise the error there otherwise it will immediately terminate the whole process. So we store it on the client and check for it after the join call. If we see an error then we raise it in the perform method so that it can be handled appropriately by either retrying the notification or marking it as failed.

@SixiS SixiS force-pushed the apnsp8-http2-fix-error-recovery branch from cb7e997 to 7845c53 Compare April 7, 2025 16:40
benlangfeld
benlangfeld previously approved these changes Jun 30, 2025
@benlangfeld
Copy link
Collaborator

Hey @SixiS , I don't have permission to push to this branch to fix the conflicts. Could you do that for merge? Sorry for the delay in reviewing this one.

@SixiS SixiS force-pushed the apnsp8-http2-fix-error-recovery branch from 7845c53 to 6db335d Compare July 1, 2025 08:44
@SixiS SixiS force-pushed the apnsp8-http2-fix-error-recovery branch from 6db335d to dca2264 Compare July 1, 2025 08:55
@SixiS
Copy link
Contributor Author

SixiS commented Jul 1, 2025

Hey @benlangfeld, rebased off master and resolved the conflict.
Thanks so much for reviewing!

@benlangfeld benlangfeld merged commit 6792e8c into rpush:master Jul 1, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy