【发布时间】:2016-12-19 18:57:52
【问题描述】:
我在我的 PHP 应用程序中使用 AWS SNS 服务将消息发送到队列。
如果互联网连接中断,应用程序应继续运行而不写入消息。但是在队列上发布消息的方法有很长的超时时间,这使得应用程序在没有互联网的情况下无法使用。
我没有在 AWS SDK 中找到可以设置更小超时的任何地方。 有没有办法做到这一点?
这里是 snsClient 对象的构造示例。
正如@Anthony Neace 所说,我已经编辑了参数以使用http timeout,我也尝试使用request.options connect_timeout,因为我在这里找到了http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html
我已经更改了我的 PC 的网关以模拟 Internet 关闭时出现的异常 [curl] 28: Resolving timed out after 3000 毫秒 https://sns.sa-east-1.amazonaws.com/
use Aws\Sns\SnsClient;
SnsClient::factory([
'version' => '...',
'region' => '...',
'credentials' => [
'key' => '...',
'secret' => '...',
],
'http' => [
'timeout' => 5
],
'request.options' => [
'connect_timeout' => 5
]
]);
【问题讨论】:
标签: php amazon-web-services aws-sdk amazon-sns