AWS S3 cURL超时

时间:2017-05-31 18:31:26

标签: php amazon-web-services curl amazon-s3

通常,AWS S3在我的网站中运行良好。但是,下载时我会随机获取这些错误:

Error retrieving credentials from the instance profile metadata server. (cURL error 28: Operation timed out after {>1000} milliseconds with 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html))

为什么呢?如何防止这些错误发生?

我正在使用AWS SDK PHP v3。

1 个答案:

答案 0 :(得分:2)

如果您使用下面的凭据

$s3 = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'us-east-1',
        'key' => "AKIAJAAAXXYASASASASDSUAG66MA",
        'secret'  => "8sZyAAAAXUSuUK3FJSDFSDS&D*SDSJFSFShjssa7Fx+GS9"
    )
]);

然后改为喜欢这个

   $s3 = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'us-east-1',
        'credentials' => array(
            'key' => "AKIAJAAAXXYASASASASDSUAG66MA",
            'secret'  => "8sZyAAAAXUSuUK3FJSDFSDS&D*SDSJFSFShjssa7Fx+GS9"
        )
    ]);