首页 > 解决方案 > Google API 卷曲超时

问题描述

从昨天开始,我在日志中看到了很多这样的错误:

Operation timed out after 100001 milliseconds with 0 bytes received
File: /var/www/html/vendor/google/apiclient/src/Google/IO/Curl.php(126)
Trace: #0 /var/www/html/vendor/google/apiclient/src/Google/IO/Abstract.php(136): Google_IO_Curl->executeRequest(Object(Google_Http_Request))
#1 /var/www/html/vendor/google/apiclient/src/Google/Http/REST.php(60): Google_IO_Abstract->makeRequest(Object(Google_Http_Request))
#2 /var/www/html/vendor/google/apiclient/src/Google/Task/Runner.php(174): Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request))
#3 /var/www/html/vendor/google/apiclient/src/Google/Http/REST.php(46): Google_Task_Runner->run()
#4 /var/www/html/vendor/google/apiclient/src/Google/Client.php(593): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#5 /var/www/html/vendor/google/apiclient/src/Google/Service/Resource.php(240): Google_Client->execute(Object(Google_Http_Request))
#6 /var/www/html/vendor/google/apiclient/src/Google/Service/Drive.php(2000): Google_Service_Resource->call('update', Array, 'Google_Service_...')
#7 /var/www/html/app/lib/GoogleDriveHelper.php(185): Google_Service_Drive_Files_Resource->update('1jbLDzGVNNNigA...', Object(Google_Service_Drive_DriveFile), Array)
#8 /var/www/html/app/lib/GoogleDriveHelper.php(131): GoogleDriveHelper->updateFile('1jbLDzGVNNNigA...', '/tmp/tr-filesUI...')
#9 /var/www/html/app/lib/GoogleDriveHelper.php(66): GoogleDriveHelper->createOrUpdateFileOnce('Folder/Photo_...', 'Filen...', '/tmp/tr-filesUI...', 'image/jpeg', '', true)
#10 /var/www/html/app/jobs/worker/taskresult-photo-upload-to-gdrive.php(170): GoogleDriveHelper->createOrUpdateFile('Folder/Photo_...', 'Filen...', '/tmp/tr-filesUI...', 'image/jpeg')
#11 [internal function]: upload_photos_to_gdrive(Object(GearmanJob), NULL)
#12 /var/www/html/app/jobs/uploads-worker.php(5): GearmanWorker->work()

我已尝试检查Google 服务状态页面,但没有报告任何问题。我以前从未见过这种异常发生过,我这边也没有任何改变。

我应该注意到这种情况很少发生,有时 Google Drive 会响应 502 错误状态代码和以下消息:

<p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.  <ins>That’s all we know.</ins>

也许您一直在解决这个问题,并且可以指出我正在发生的事情的解释,这是可以预防的(如果可以的话 - 如何)或者这些问题是否在我的服务方面?

标签: phpcurlgoogle-apigoogle-drive-apitimeout

解决方案


对于 500 个错误,您无能为力,它们是谷歌方面的错误。按照文档中的建议,您应该实施指数退避。

如果您收到 500 错误,请等待几秒钟,然后重试。如果它仍然不起作用,则等待两倍的时间,如果仍然不起作用,则等待三倍的时间。

如果说 15 次尝试后它仍然不起作用,那么可能是有问题了。 指数退避

超文本传输​​协议 (HTTP) 502 Bad Gateway 服务器错误响应代码表示服务器在充当网关或代理时,收到了来自上游服务器的无效响应。


推荐阅读