Increase the Guzzle HTTP Client request timeout in Drupal 8
During some migration operations on a Drupal 8 site, I needed to make an HTTP request that took > 30 seconds to return all the data... and when I ran the migration, I'd end up with exceptions like:
Migration failed with source plugin exception: Error message: cURL error 28: Operation timed out after 29992 milliseconds with 2031262 out of 2262702 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html).
The solution, it turns out, is pretty simple! Drupal's \Drupal\Core\Http\ClientFactory
is the default way that plugins like Migrate's HTTP fetching plugin get a Guzzle client to make HTTP requests (though you could swap things out if you want via services.yml
), and in the code for that factory, there's a line after the defaults (where the 'timeout' => 30
is defined) like: