aws-sdk-php: Intermittent PutObject Failures
Everyday I get 1-10 of these errors out of a couple thousand putObject requests and the putObject fails. I have thousands more of requests using curl to other servers daily with no problems so I don’t see it being my server at fault right now.
Code (PHP 5.5.28, Apache 2.4.16)
include('composer/vendor/autoload.php');// latest version of SDK 3.3.6
$s3=new Aws\S3\S3Client(['version'=>'latest','region'=>'us-east-1','credentials'=>['key'=>KEY,'secret'=>SECRET],'scheme'=>'http']);
$s3->putObject(['Key'=>$name,'Bucket'=>BUCKET,'Body'=>$image_data,'ACL'=>'public-read','ContentType'=>'image/jpg')]);//fails here intermittently
Exception (Everyday 1-10 of these similar messages)
PHP Fatal error: Uncaught exception ‘Aws\S3\Exception\S3Exception’ with message ‘Error executing “PutObject” on “http://s3.amazonaws.com/mybucket/image055f80f4f085ee.jpg”; AWS HTTP error: cURL error 56: Recv failure: Connection reset by peer (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)’
exception ‘GuzzleHttp\Exception\RequestException’ with message ‘cURL error 56: Recv failure: Connection reset by peer (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)’ in /home/public_html/composer/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187 Stack trace: #0 /home/public_html/composer/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /home/public_html/composer/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlMultiHandler), Object(GuzzleHttp\Handler\EasyHandle), Obj in /home/public_html/composer/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 152
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Ensure connection reset errors are retried. Resolves #767 — committed to jeskew/aws-sdk-php by jeskew 9 years ago
- Ensure connection reset errors are retried. Resolves #767 — committed to jeskew/aws-sdk-php by jeskew 9 years ago
- Ensure connection reset errors are retried. Resolves #767 — committed to jeskew/aws-sdk-php by jeskew 9 years ago
Reset connection errors are retried up to three times before the request fails. You could try increasing that value by passing adding a
retries
key in the options array being passed to the client constructor:I suspect that you would see fewer reset connections if you allowed the SDK to use https, but I don’t have any numbers to back that up.