错误在于您的机器和服务之间的 TLS|SSL 协商。它可能是您的机器、中介或 Google。
你在代理后面吗?如果有代理,它可能正在拦截呼叫。
你能用gcloud 或者gcloud functions list 做其他事情吗?如果您可以特别针对 Cloud Functions 发出其他命令,这就增加了对 Google 问题的怀疑。如果你不能,那么很有可能是你的客户端(和|或代理)出错了
如果您将--log-http 附加到部署(或任何gcloud)命令,您将收到更详细的日志记录,这可能会识别错误。
更新(Python)
我尝试通过创建新项目而不启用计费来重现错误。我使用了 hello-world 示例 (link),并且能够毫无问题地进行部署和测试。我怀疑这个问题要么是服务器(或地区)的间歇性问题。或者,更有可能是您机器上的配置问题。
def hello_world(request):
return "Hello World"
和 requirements.txt:
flask==1.1.1
然后:
PROJECT=[[YOUR-PROJECT-ID]]
REGION=us-east1
gcloud projects create ${PROJECT}
gcloud services enable cloudfunctions.googleapis.com \
--project=${PROJECT}
gcloud functions deploy hello_world \
--region=${REGION} \
--project=${PROJECT} \
--entry-point=hello_world \
--runtime=python37 \
--source=${PWD} \
--trigger-http
部署成功后,我可以:
URL=$(\
gcloud functions describe hello_world \
--region=${REGION} \
--project=${PROJECT} \
--format="value(httpsTrigger.url)")
curl \
--silent \
--request GET \
"${URL}"
Hello World
更新(Node.JS)
很抱歉 ;-)
exports.helloWorld = (req, res) => {
res.status(200).send("Hello World");
};
package.json:
{
"name": "hello-world",
"version": "0.0.1",
"dependencies": {}
}
还有:
gcloud functions deploy hello_world \
--region=${REGION} \
--project=${PROJECT} \
--entry-point=helloWorld \
--runtime=nodejs10 \
--source=${PWD} \
--trigger-http
否则与之前使用 Python 一样。
工作。