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

best way to handle ServerError and ServerUnavailable Exception #45

Closed
michaelnguyen2021 opened this issue Jul 2, 2020 · 4 comments
Closed

Comments

@michaelnguyen2021
Copy link

I usually have a queued job to process sending a push notification. When the job gets a ServerError or ServerUnavailable Exception, it will retry immediately until it runs out of the number of tries.

Ideally, if the job gets the ServerError or ServerUnavailable. It should wait for 30s before trying again. I am not sure how to do this? Any suggestions?

@jeromegamez
Copy link
Member

Is the retryAfter behavior in the job class perhaps what you‘re after?

https://laravel-news.com/job-based-retry-delay

@michaelnguyen2021
Copy link
Author

@jeromegamez I ended up using

       try {
            app('firebase.messaging')->send($message);
        } catch (NotFound $e) {
            $this->device->delete();
        } catch (ServerError $e) {
            $this->release($this->attempts() * 10);
        }

I have some weird issue with retryAfter where the retryAfter time does not increment by the number of attempts.

This brings me to the next question: how to try and catch for all app('firebase.messaging')->send($message); without copy and paste try/catch where I use app('firebase.messaging')->send($message);

@jeromegamez
Copy link
Member

You can catch the MessagingException interface (https://github.com/kreait/firebase-php/blob/main/src/Firebase/Exception/MessagingException.php).

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Sep 1, 2020
@github-actions github-actions bot closed this as completed Sep 8, 2020
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

2 participants