XF 2.3 What is the Webhook's retry policy in case of failure?

BubbaLovesCheese

Active member
Does the webhook reattempt delivery if it does not receive a 2xx status code response from the listener endpoint?

If so, does anyone know the details on the retry schedule (number of retries, intervals, etc.) before it is marked as failed?

And is there any documentation on this?

Thanks!
 
Solution
Does the webhook reattempt delivery if it does not receive a 2xx status code response from the listener endpoint?
Yes.

If so, does anyone know the details on the retry schedule (number of retries, intervals, etc.) before it is marked as failed?
3 retries - after 5, 10 and 20 minutes (by default, could be changed by a class extension).

And is there any documentation on this?
XF\Job\Retryable and XF\Job\WebhookSend
Does the webhook reattempt delivery if it does not receive a 2xx status code response from the listener endpoint?
Yes.

If so, does anyone know the details on the retry schedule (number of retries, intervals, etc.) before it is marked as failed?
3 retries - after 5, 10 and 20 minutes (by default, could be changed by a class extension).

And is there any documentation on this?
XF\Job\Retryable and XF\Job\WebhookSend
 
Solution
Thanks!

If anyone wanted to add custom webhook retries, you can add this to the src\XF\Job\Retryable file.

PHP:
class CustomWebhookSend extends WebhookSend
{
    protected function calculateNextAttemptDate(int $previousAttempts): ?int
    {
        // Add any custom timing logic you want below

        if ($previousAttempts < 6) {
            // Every 10 seconds for the first minute (6 attempts)
            $delay = 10;
        }
        elseif ($previousAttempts < 21) {
            // Every 20 seconds for the next 5 minutes (15 attempts)
            $delay = 20;
        }
        elseif ($previousAttempts < 61) {
            // Every 30 seconds for the next 20 minutes (40 attempts)
            $delay = 30;
        }
        elseif ($previousAttempts < 121) {
            // Every 60 seconds for the next 1 hour (60 attempts)
            $delay = 60;
        }
        elseif ($previousAttempts < 1081) {
            // Every 180 seconds for the next 48 hours (960 attempts)
            $delay = 180;
        }
        else {
            // No further retries beyond these limits
            return null;
        }

        return time() + $delay;
    }
}
 
Last edited:
Back
Top Bottom