phpcurllibcurlgoogle-shopping-api

PHP Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 2: easy handle already used in multi handle


I am a user not a developer. The developer is not available.

This is the Google API library used in Google Shopping Products submission scripts.

The scripts worked successfully, every 20 minutes, for 2 years + the first 5 hours of yesterday.

Then the following error:

[18-Apr-2020 06:20:03 Europe/London] PHP Fatal error:  Uncaught GuzzleHttp\Exception\RequestException: cURL error 2: easy handle already used in multi handle (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in ../vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:162
Stack trace:
#0 ../vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(129): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 ../vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(89): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 ../vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(ThObject(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 ../vendor/guzzlehttp/guzzle/src/Handl in ../vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 162

The only server change at around the time the scripts stopped working was a security patch applied to the physical host and a server reboot.

PHP v7.3.16

I believe the Google library in use is v2.0

I can follow instructions although will probably not understand them!

TIA


Solution

  • Just in case anyone reading this is using Laravel. We suddenly started having the same problem a few days ago, tried installing different cURL versions and setting cURL options, nothing worked. I fixed it by changing the vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php file. Look for the line that says

    if (count($this->handles) >= $this->maxHandles) {
    curl_close($resource);
    } else {
    ...
    }
    

    Comment this all out, and instead of the if/else just write

    curl_close($resource);
    

    In other words no matter what the handles count is you always close the cURL connection. This worked instantly for us!

    Hope it helps :)