【问题标题】:Google Cloud Endpoints using Google Cloud Run Error: could not handle the request使用 Google Cloud Run 的 Google Cloud Endpoints 错误:无法处理请求
【发布时间】:2020-01-20 05:25:50
【问题描述】:

我已经设置了指向 Google Functions 的 Google Cloud 端点 (open-api.yaml)。我已经使用 Google Cloud Run 创建了 API Gateway 服务器。我测试了同样的,发现它工作正常。

在 YAML 和 Google 函数中进行了一些更新后,我现在收到 错误:无法处理请求。这是服务器 500 错误。 YAML文件如下:

swagger: '2.0'
info:
  title: API gateway
  description: Gateway on Cloud Endpoints with a Google Cloud Functions backend
  version: 1.0.0
host: xxxx-service-abcd-uc.a.run.app
schemes:
  - https
produces:
  - application/json
paths:
  /auth/signup:
    post:
      summary: Create a new user
      operationId: authSignup
      x-google-backend:
        address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
        path_translation: APPEND_PATH_TO_ADDRESS
      responses:
        '200':
          description: A successful response
          schema:
            type: string
  /auth/login:
    post:
      summary: Logs in an existing user
      operationId: authLogin
      x-google-backend:
        address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
        path_translation: APPEND_PATH_TO_ADDRESS
      responses:
        '200':
          description: A successful response
          schema:
            type: string
  /auth/check:
    get:
      summary: check
      operationId: authCheck
      x-google-backend:
        address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
        path_translation: APPEND_PATH_TO_ADDRESS
      responses:
        '200':
          description: A successful response
          schema:
            type: string

当我通过 Postman 的 post 调用调用 url:https://xxx--service-abcd-uc.a.run.app/auth/login 或使用 Postman 或浏览器的 get 调用 https://xxxx-service-abcd-uc.a.run.app/auth/check 时,我收到此错误。

Google Cloud Run 上的日志只有以下条目:

GET 500 700 B 184 msChrome 79 https://xxxx-service-abcd-uc.a.run.app/auth/check

POST 500 622 B 99 PostmanRuntime/7.22.0 https://xxxx-service-abcd-uc.a.run.app/auth/login

由于它是早期工作的,所以肯定有一些我无法检测到的愚蠢错误。感谢您的帮助。

【问题讨论】:

  • 如果我理解正确,您提供了一个由 Cloud Run 执行的 Docker 容器。如果你直接定位它,它会起作用吗?
  • 感谢@Kolban 的回复。是的,我使用了 Google 文档建议的容器来运行端点。当我调用 Google Run url 时,它给了我同样的错误。请注意,在日志中,我使用 Postman 和 Chrome 浏览器方法直接调用 Post 和 Get 路由。我检查的谷歌功能有效
  • 我承认我昨天让它工作了......只是做了一些改变。因此,我怀疑我在 yaml 中搞砸了一些事情
  • 这是我遵循的步骤:cloud.google.com/endpoints/docs/openapi/…

标签: google-cloud-run google-cloud-endpoints-v2


【解决方案1】:

我删除了 Google Run 服务并使用简单的 API 路径重新创建它,它似乎可以工作。

【讨论】:

  • 当您说您使用简单的 API 路径重新创建它时,这是否意味着您必须以任何方式更改 openapi-functions.yaml
  • 是的。如前所述,我让它工作。然后,当我增强 yaml(添加更多路径)和 google 函数中的逻辑以满足它们时,它被炸毁了。只是想在这里记录一下,也许这个错误是我的错。
猜你喜欢
  • 2019-10-27
  • 1970-01-01
  • 2019-12-20
  • 2021-11-22
  • 2020-12-24
  • 2018-12-18
  • 1970-01-01
  • 2020-12-02
  • 2017-11-29
相关资源
最近更新 更多