Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

HTTP Client Retry

Security covered Drupal 10–11
View on drupal.org

About

HTTP Client Retry adds a middleware to the core http.client service to retry HTTP requests automatically when they fail with certain (configurable) response status code.

Requirements

The Guzzle Retry Middleware package is required to be installed to use this module. It should be installed automatically when adding this module via composer. If not, use the following command to install it to your base repository: composer require caseyamcl/guzzle_retry_middleware

Installation

Install as you would normally install a contributed Drupal module. See Installing Modules for more information.

Configuration

Visit Configuration » System » HTTP Client Retry (/admin/config/system/http_client_retry) to enable and configure module settings.

Other Functionality

Request retry event

Whenever a request is retried a \Drupal\http_client_retry\Event\RequestRetryEvent event (http_client_retry.request.retry) is dispatched. This event includes details about the retrying status, configuration information for the retries, the original request object, and the current response object. Event subscribers can be used to take action on this event (this is also how the module itself handles optional retry logging).

Per request configuration

The middleware provided by this module can also be configured on individual requests using http.client service (i.e. in custom code). See the Guzzle Retry Middleware README file for more details. For example, to only enable the retry functionality for specific request the module configuration can set retries to disabled and then pass configuration on the request like so:

>>> $client = Drupal::service('http_client');
>>> $client->request('GET', 'https://httpstat.us/503', ['retry_enabled' => TRUE]);
 [warning] Retrying request to https://httpstat.us/503. Server responded with 503. Will wait 1.50 seconds. This is attempt #1.
 [warning] Retrying request to https://httpstat.us/503. Server responded with 503. Will wait 3.00 seconds. This is attempt #2.
 [warning] Retrying request to https://httpstat.us/503. Server responded with 503. Will wait 4.50 seconds. This is attempt #3.
GuzzleHttp\Exception\ServerException with message 'Server error: `GET https://httpstat.us/503` resulted in a `503 Service Unavailable` response'
>>> 

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
May 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Active

Releases

Version Type Core Release date
2.0.2 Stable 10–11 Sep 7, 2024
2.0.1 Stable May 16, 2023