You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful for logging and reporting reasons to know get access to the exception that caused the retry in the on_retry_callback. I have not found a way to log what type of error that caused a retry due to a ConnectException.
Context
my setup looks like this:
GuzzleRetryMiddleware::factory([
'max_retry_attempts' => 5,
'give_up_after_secs' => 20,
'retry_on_status' => [429, 500, 502, 503, 504],
// This is not only timeouts, it is all ConnectException (https://github.com/caseyamcl/guzzle_retry_middleware/blob/v2.9.0/src/GuzzleRetryMiddleware.php#L239C55)'retry_on_timeout' => true,
'on_retry_callback' => function (int$attemptNumber, float$delay, RequestInterface &$request, array &$options, ?ResponseInterface$response) {
$maxAttempt = $options['max_retry_attempts'];
$cause = $response ? "response status: {$response->getStatusCode()}" : 'Unknown cause';
$this->logger->warning("Retrying request ($attemptNumber/$maxAttempt) in {$delay}ms. cause: $cause");
}
])
As you can see i'm forces to log Unknown cause if a ConnectException occurred as there is no response in that case.
Possible implementation
One possible solution could be to change the signature of the doRetry function to something like this:
Detailed description
It would be useful for logging and reporting reasons to know get access to the exception that caused the retry in the on_retry_callback. I have not found a way to log what type of error that caused a retry due to a ConnectException.
Context
my setup looks like this:
As you can see i'm forces to log
Unknown cause
if a ConnectException occurred as there is no response in that case.Possible implementation
One possible solution could be to change the signature of the
doRetry
function to something like this:using
GuzzleHttp\Exception\RequestException
as that includes bothBadResponseException
andConnectException
I can help with the implementation if you think that it is a good idea
The text was updated successfully, but these errors were encountered: