[英]How do we minimise the timeout when using Google Cloud PubSub Client Library for php?
We have been getting these exceptions from Google this evening:今晚我们从谷歌那里得到了这些例外:
Google\\Cloud\\Core\\Exception\\ServiceException: cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html )
Google\\Cloud\\Core\\Exception\\ServiceException:cURL 错误 56:OpenSSL SSL_read:SSL_ERROR_SYSCALL,errno 104(参见http://curl.haxx.se/libcurl/c/libcurl-errors.html )
Google\\Cloud\\Core\\Exception\\ServiceException(code: 0): cURL error 7: Failed to connect to oauth2.googleapis.com port 443: Connection timed out (see http://curl.haxx.se/libcurl/c/libcurl-errors.html )
Google\\Cloud\\Core\\Exception\\ServiceException(代码:0):cURL 错误 7:无法连接到 oauth2.googleapis.com 端口 443:连接超时(请参阅http://curl.haxx.se/libcurl/c/ libcurl-errors.html )
Google\\Cloud\\Core\\Exception\\ServiceException(code: 0): cURL error 28: Operation timed out after 2001 milliseconds with 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html )
Google\\Cloud\\Core\\Exception\\ServiceException(代码:0):cURL 错误 28:操作在 2001 毫秒后超时,收到 0 个字节(参见http://curl.haxx.se/libcurl/c/libcurl-errors.html )
We can handle the exceptions fine, but there is a significant timeout between the connection initiation and the exception occurring.我们可以很好地处理异常,但是在连接启动和异常发生之间存在明显的超时。 This means our server hangs for a long period of time as a request is initiated to Google, waits for connection to be properly created, fails, and then continues.
这意味着我们的服务器在向 Google 发起请求时会长时间挂起,等待连接正确创建,失败,然后继续。 This means our requests take a ridiculous amount of time (~20 seconds - 3 minutes approximately) instead of milliseconds.
这意味着我们的请求花费了大量的时间(大约 20 秒 - 大约 3 分钟)而不是毫秒。
So:所以:
We're using the PHP PubSubClient, specifically only the publish
method at the moment.我们正在使用 PHP PubSubClient,特别是目前仅使用
publish
方法。
I believe this can be fixed by the following:我相信这可以通过以下方式解决:
$pubsub->publish(
[
'data' => $data,
'attributes' => $attributes,
],
[
'requestTimeout' => 2 // Set your own value here (in seconds)
]
);
This seems to be translated into a Guzzle option under the hood.这似乎被转化为引擎盖下的 Guzzle 选项。
See \\Google\\Cloud\\Core\\RestTrait::send
for more info查看
\\Google\\Cloud\\Core\\RestTrait::send
了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.