Skip to content
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

curl error when pusing to apns #175

Open
algesiaResidue opened this issue May 9, 2024 · 8 comments
Open

curl error when pusing to apns #175

algesiaResidue opened this issue May 9, 2024 · 8 comments

Comments

@algesiaResidue
Copy link

Sometimes, We got this error when pusing to apns: Operation timed out after 0 milliseconds with 0 out of 0 bytes received. The frequence is once or twice a day.

@edamov
Copy link
Owner

edamov commented May 9, 2024

It is hard to fix such error. Maybe the problem is on apple server side.
The only way I see is to add try/catch block and send request again in case of error. You can implement it on your side.
But also I may try to add this logic in library. Can you somehow store the whole response (status code, headers, body) from APNS and send me?

@algesiaResidue
Copy link
Author

algesiaResidue commented May 9, 2024

unfortunatly, curl http code is 0, thus throwing this exception in Client.php line 161, and there is no valid response.

@algesiaResidue
Copy link
Author

maybe adding a retry function when curl get code 0 is a good idea.

@dlucian
Copy link

dlucian commented May 10, 2024

But then, since the whole sending crashes on one timeout, one would need to check which notifications where sent and re-try the sending with just the ones that were not sent, right?

Which can't be done, since Client::push() doesn't return the responses anymore, but throws instead. So we don't know which notifications were sent and which not. Or am I missing something?

@algesiaResidue
Copy link
Author

But then, since the whole sending crashes on one timeout, one would need to check which notifications where sent and re-try the sending with just the ones that were not sent, right?

Which can't be done, since Client::push() doesn't return the responses anymore, but throws instead. So we don't know which notifications were sent and which not. Or am I missing something?

You can't just throw this exception, but handle it yourself instead. When curl http code got 0, you should add that notification to multi curl handler again to be sent later.

@dlucian
Copy link

dlucian commented May 14, 2024

But then, since the whole sending crashes on one timeout, one would need to check which notifications where sent and re-try the sending with just the ones that were not sent, right?
Which can't be done, since Client::push() doesn't return the responses anymore, but throws instead. So we don't know which notifications were sent and which not. Or am I missing something?

You can't just throw this exception, but handle it yourself instead. When curl http code got 0, you should add that notification to multi curl handler again to be sent later.

No, the Client class throws \Exception, not me. And when it it's thrown, there's no list of successfully sent notifications, so I don't know which to retry.

@algesiaResidue
Copy link
Author

You can rewrite this method, and add retry mechanism. I just did this, and the error never affected my pushing project again lol.

@algesiaResidue
Copy link
Author

Sorry for the misinformation, after adding the retry mechanism ,this issue still bothers me, apns server will continue to deny this notification in next few minutes which means you need retry through this time span. I've figure out a solution, I recommand you use swoole http2 client and connection pool to maintain these connections. you can refer to https://wiki.swoole.com/zh-cn/#/coroutine_client/http2_client for more information.

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

No branches or pull requests

3 participants