【问题标题】:Getting an error when attempting to deploy a Cloud Function using the gcloud CLI尝试使用 gcloud CLI 部署云函数时出错
【发布时间】:2023-03-19 23:31:01
【问题描述】:

当我尝试使用 gcloud CLI 部署 Google Cloud Function 时,出现以下错误:

ERROR: (gcloud.functions.deploy) EOF occurred in violation of protocol (_ssl.c:727)
This may be due to network connectivity issues. Please check your network settings, and the status of the service you are trying to reach.

我重新安装了 gcloud 命令行工具,还运行了 brew upgrade 来更新 brew 包,但对我不起作用。为什么会出现此错误?

【问题讨论】:

  • 您能否提供有关您要更新的内容的更多信息?您还应该检查您使用 brew 更新的软件包,可能没有正确安装或更新某些内容,这可能是您无法部署的原因。你可以试试:brew list | xargs brew reinstall

标签: google-cloud-platform google-cloud-functions gcloud


【解决方案1】:

错误在于您的机器和服务之间的 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 一样。

工作。

【讨论】:

  • 是的,当我运行gcloud functions list 时它可以工作。但是部署命令没有工作。
  • 有趣这可能不是您的本地配置。您是否也尝试将--log-http 添加到部署中?这可能会提供更多详细信息
  • 您要部署什么样的应用程序?是 Python 的吗?问题似乎与 SSL 安装有关。如果您使用的是 Python,我建议 pip install pyopenssl 或者如果不尝试使用 homebrew 升级您的 openssl 版本。
  • 不,这不是 python 函数。这是nodejs函数。
  • 道歉。修改了答案以包含一个 Node.JS 示例。这也有效。
猜你喜欢
  • 1970-01-01
  • 2020-03-26
  • 2021-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-05
  • 2018-01-10
  • 2021-09-25
相关资源
最近更新 更多