【问题标题】:GCP - Cloud Run with gRPC - Bookstore ExampleGCP - 使用 gRPC 的云运行 - 书店示例
【发布时间】:2020-09-10 11:26:54
【问题描述】:

我正在尝试在 gcp cloud run 上运行 gRPC 演示服务。我遵循了 Google 官方文档。

https://cloud.google.com/endpoints/docs/grpc/get-started-cloud-run

按照本教程中的步骤进行操作后,我已经成功地在我的 gcp 项目上部署了云运行服务。之后,我向服务的端点发送了请求,但请求没有到达服务。我在 google Stackdriver 中找不到访问日志。

python3 bookstore_client.py --host xx-xxxxx-ew.a.run.app --port 443 --use_tls true

设置 ENDPOINTS_SERVICE_NAME 环境变量(不是官方 google 文档的一部分)后,我能够针对服务发送请求。

目前我收到以下错误:

收到状态为 413 的 http2 标头

这意味着有效载荷很大。

整个错误是:

Traceback (most recent call last):
  File "bookstore_client.py", line 64, in <module>
    run(args.host, args.port, args.api_key, args.auth_token, args.timeout, args.use_tls)
  File "bookstore_client.py", line 41, in run
    shelves = stub.ListShelves(empty_pb2.Empty(), timeout, metadata=metadata)
  File "/opt/Anaconda3-5.1.0-Linux-x86_64/envs/_banned_objects/lib/python3.6/site-packages/grpc/_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/opt/Anaconda3-5.1.0-Linux-x86_64/envs/_banned_objects/lib/python3.6/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.CANCELLED
    details = "Received http2 header with status: 413"
    debug_error_string = "{"created":"@1589980909.573607403","description":"Received http2 :status header with non-200 OK status","file":"src/core/ext/filters/http/client/http_client_filter.cc","file_line":121,"grpc_message":"Received http2 header with status: 413","grpc_status":1,"value":"413"}"

该服务的最大内存大小为 2 GB,并且使用一个 CPU 运行。 该请求是教程中的正常请求。 我错过了什么?

【问题讨论】:

  • KalanyuZ 提供的建议是否解决了您的问题,还是您仍然面临问题?
  • 您是否使用云端点?从您的问题/标签中不清楚这部分。

标签: python-3.x google-cloud-platform grpc google-cloud-run


【解决方案1】:

我遇到了同样的问题,但我的是 nodejs 实现。可能是在Configuring Endpoints 的第 2 点中,您必须按如下方式配置 api_config.yaml:

# The configuration schema is defined by the service.proto file.
# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto

type: google.api.Service
config_version: 3
name: CLOUD_RUN_HOSTNAME
title: Cloud Endpoints + Cloud Run gRPC
apis:
  - name: endpoints.examples.bookstore.Bookstore
usage:
  rules:
  # ListShelves methods can be called without an API Key.
  - selector: endpoints.examples.bookstore.Bookstore.ListShelves
    allow_unregistered_calls: true
backend:
  rules:
    - selector: "*"
      address: grpcs://python-grpc-bookstore-server-HASH-uc.a.run.app

您是否使用了 CLOUD_RUN_HOSTNAME 甚至不正确的云运行服务名称作为 grpcs://python-grpc-bookstore-server-HASH-uc.a.run.app

我使用了错误的名称,当我更改它并重新部署服务时,它按预期工作。

【讨论】:

    猜你喜欢
    • 2018-11-23
    • 2019-04-07
    • 1970-01-01
    • 2021-08-19
    • 2021-08-15
    • 2021-09-28
    • 2021-11-29
    • 2021-10-30
    • 2020-04-26
    相关资源
    最近更新 更多