google-cloud-platform - 如何解决 gcloud 崩溃 (ReadTimeout):HTTPSConnectionPool(host='cloudfunctions.googleapis.com', port=443):读取超时。(读取超时=300)
问题描述
使用终端中的 gcloud 命令触发云功能时收到错误消息:
gcloud functions call function_name
在云功能日志页面上没有显示错误并且任务完成没有问题,但是,在任务完成后,该错误显示在终端上。
gcloud crashed (ReadTimeout): HTTPSConnectionPool(host='cloudfunctions.googleapis.com', port=443): Read timed out. (read timeout=300)
注意:我的功能超时设置为 540 秒,完成工作需要约 320 秒
解决方案
我认为问题在于gcloud functions call
300 秒后超时,并且无法配置更长的超时时间以匹配云功能。
我创建了一个简单的 Golang 云函数:
func HelloFreddie(w http.ResponseWriter, r *http.Request) {
log.Println("Sleeping")
time.Sleep(400*time.Second)
log.Println("Resuming")
fmt.Fprint(w, "Hello Freddie")
}
并部署它:
gcloud functions deploy ${NAME} \
--region=${REGION} \
--allow-unauthenticated \
--entry-point="HelloFreddie" \
--runtime=go113 \
--source=${PWD} \
--timeout=520 \
--max-instances=1 \
--trigger-http \
--project=${PROJECT}
然后我time
用它gcloud functions call ${NAME} ...
time \
gcloud functions call ${NAME} \
--region=${REGION} \
--project=${PROJECT}
这超时了:
ERROR: gcloud crashed (ReadTimeout): HTTPSConnectionPool(host='cloudfunctions.googleapis.com', port=443): Read timed out. (read timeout=300)
real 5m1.079s
user 0m0.589s
sys 0m0.107s
注意
5m1s
~== 300s
但是,使用curl
:
time \
curl \
--request GET \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
$(\
gcloud functions describe ${NAME} \
--region=${REGION}
--project=${PROJECT} \
--format="value(httpsTrigger.url)")
产量:
Hello Freddie
real 6m43.048s
user 0m1.210s
sys 0m0.167s
注意
6m43s
~==400s
因此,gcloud functions call
300 秒后超时,这是不可配置的。
向 Google 的问题跟踪器提交了问题。
推荐阅读
- xamarin - 无效字符 Arduino、蓝牙 (HM10) 和 Xamarin.Forms
- python-3.x - 在 Python3/Tkinter 中创建随机大小正方形的对称网格
- python - 使用 scipy.stats 拟合 xarray DataArray
- kubernetes - 如何更改 VolumeMount 的用户和组所有者
- javascript - 计算器运算符和函数不起作用
- azure-application-insights - 如何使用 Azure Application Insights 在 Node.js (ws) 中跟踪 WebSocket?
- javascript - 如何使用 unpkg 作为 MDC CSS 文件和 s 文件的存储在 Web 应用程序上添加 Material Design 选项卡
- jmeter - Beanshell 函数在 if/else 评估之前被调用
- sql - 差距和岛屿 - POSTGRESQL
- java - Kafka Stream Chained LeftJoin - 在新消息之后再次处理之前的旧消息