aws-sdk-php: Consecutive API calls return curl error code 35 on CentOS 6.5

After initializing the S3Client with just a key and secret, I can only make 1 API call before getting curl error code 35.

E.g.

$s3->putObject([
    'Bucket'=>'MyBucket',
    'Key'=>'MyFolder/',
    'Body'=>'',
    'ContentLength'=>0
]);

The 2nd time results in the following error:

PHP Fatal error:  Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 35:  [url] https://s3.amazonaws.com/MyBucket/MyFolder/' in /home/mike/src/awstest/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php:338
Stack trace:
#0 /home/mike/src/awstest/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(279): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#1 /home/mike/src/awstest/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(244): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#2 /home/mike/src/awstest/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(227): Guzzle\Http\Curl\CurlMulti->processMessages()
#3 /home/mike/src/awstest/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(211): Guzzle\Http\Curl\CurlMulti->executeHandles()
#4 /home/mike/src/awstest/vendor/guzzle/guz in /home/mike/src/awstest/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php on line 286

I’m hitting a bucket in the US East Region.

I’ve tried passing several combinations of curl.options to the factory constructor, but no luck

$s3 = S3Client::factory([
    'key' => '****',
    'secret' => '****',
    'curl.options' => [
        'CURLOPT_SSLVERSION' => 3,
    ]
]);

Server package details: CentOS 6.5 php 5.4.23-29 curl 7.19.7-37 openssl 1.0.1e-16

$ curl --version
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

Edit: renamed and updated details based on latest findings.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I came across this thread while looking for a solution for this problem. I just found the solution so I’m sharing it with you guys.

Starting tinker with the environment variable NSS_STRICT_NOFORK=DISABLED solves the issue. Source: https://cohanrobinson.com/php-curl-libcurl-error-on-subsequent-requests/

Latest findings (after rebuilding curl and libcurl from the source RHEL rpms) is that this might just be an artifact of trying to run commands in Laravel’s php artisan tinker shell. Stuffing the same 5 lines in a TestCase allows them to run successfully with no other hijinks.

This could be the fault of Boris.

I can confirm that this is a Tinker Shell issue. Running the same in PHP’s interactive shell everything works fine.