【问题标题】:Google AppEngine Endpoints Error: Fetching service config failed (status code 404)Google AppEngine Endpoints 错误:获取服务配置失败(状态码 404)
【发布时间】:2017-02-18 03:12:19
【问题描述】:

我正在执行Quickstart 中的步骤。

我确实注意到了another question。 我仔细检查了 app.yaml 中的 env_variables 部分是否具有正确的 ENDPOINTS_SERVICE_NAMEENDPOINTS_SERVICE_VERSION 值。

../_ah/api/explorer 在“服务”下没有显示任何端点。

这是什么错误以及如何解决?

错误日志显示:

 (/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/main.py", line 103, in <module>
    api = endpoints.api_server([EchoApi])
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/lib/endpoints/apiserving.py", line 520, in api_server
    controller)
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/lib/google/api/control/wsgi.py", line 121, in add_all
    a_service = loader.load()
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/lib/google/api/control/service.py", line 110, in load
    return self._load_func(**kw)
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/lib/google/api/config/service_config.py", line 78, in fetch_service_config
    _log_and_raise(Exception, message_template.format(status_code))
  File "/base/data/home/apps/s~test-app-129421/20170217t185546.399267289806711006/lib/google/api/config/service_config.py", line 126, in _log_and_raise
    raise exception_class(message)
Exception: Fetching service config failed (status code 404)

【问题讨论】:

    标签: python google-app-engine


    【解决方案1】:

    我有相同的异常跟踪,除了我的是 403。希望对其他有同样挫败感的人有所帮助。

    Exception: Fetching service config failed (status code 403)

    我终于在我的 app.yaml 中发现它来自 GIT 克隆

    ENDPOINTS_SERVICE_NAME: echo-api.endpoints.[YOUR-PROJECT-ID].cloud.goog

    快速入门仅指示我替换 YOUR-PROJECT-ID。

    我还必须将 .cloud.goog 替换为 .appspot.com

    【讨论】:

    • 感谢您的意见。就我而言,我没有正确的端点路径。
    • 用 .appspot.com 替换 .cloud.goog 为我解决了这个问题。谢谢。
    • 他们的文档有一段时间令人毛骨悚然。调试起来非常糟糕。
    【解决方案2】:

    我有应用调用myapp

    首秀服务:

    D:\projects\barcode\ebk>gcloud service-management configs list --service=myapp.appspot.com
    CONFIG_ID     SERVICE_NAME
    2017-06-29r3  myapp.appspot.com
    2017-06-29r2  myapp.appspot.com
    2017-06-29r1  myapp.appspot.com
    2017-06-29r0  myapp.appspot.com
    

    你可以看到结果的第一行是2017-06-29r3 myapp.appspot.com,编辑app.yaml:

    env_variables:
      # The following values are to be replaced by information from the output of
      # 'gcloud service-management deploy swagger.json' command.
      ENDPOINTS_SERVICE_NAME: myapp.appspot.com
      ENDPOINTS_SERVICE_VERSION: 2017-06-29r3
    

    这对我有用

    【讨论】:

      【解决方案3】:

      如果获取服务配置失败并返回 404,则gcloud service-management deploy 步骤可能没有按预期工作。我会再次尝试该步骤,确保一切配置正确,并确保命令完成且没有错误。

      【讨论】:

      • 谢谢布拉德。我将查看该步骤的日志。那些寻找我如何解决这个问题的人:我碰巧通过使用不同的工作示例作为模板来解决这个问题,并且可以解决这个问题。
      【解决方案4】:

      您只需按照以下步骤操作:

      1. 通过运行以下命令显示服务配置 ID:

        gcloud endpoints configs list --service=echo-api.endpoints.[PROJECT-ID].cloud.goog
        
      2. 将 [PROJECT-ID] 替换为您的项目 ID。不要包括方括号。

      3. 编辑 python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo 目录中的 app.yaml 文件,并在 env_variables 部分进行以下更改:

        env_variables:
          # Replace with your endpoints service name.
          ENDPOINTS_SERVICE_NAME: "echo-api.endpoints.[PROJECT-ID].cloud.goog"
          # Replace with the version Id of your uploaded Endpoints service.
          ENDPOINTS_SERVICE_VERSION: "[YOUR-SERVICE-CONFIG-ID]"
        
      4. 将 [PROJECT-ID] 替换为您的项目 ID,将 [YOUR-SERVICE-CONFIG-ID] 替换为上一步中的服务配置 ID。不要包括方括号。例如:

        env_variables:
          # Replace with your endpoints service name.
          ENDPOINTS_SERVICE_NAME: "echo-api.endpoints.example-project.cloud.goog"
          # Replace with the version Id of your uploaded Endpoints service.
          ENDPOINTS_SERVICE_VERSION: "2016-12-14r1"
        

      您只需选择第一个命令中显示的选项之一。

      【讨论】:

      • 我相信现在是gcloud services list - 替换gcloud service-management configs list
      • 现在他们有一个特定于端点的组,我认为该命令现在看起来有点像:gcloud endpoints configs list --service=echo-api.endpoints.[PROJECT-ID].cloud.goog
      【解决方案5】:

      使用 Cloud Endpoint 时,必须确保配置 ID 与 app.yaml 中的相同

      gcloud endpoints configs list --service=myapp.appspot.com
      

      结果:

      CONFIG_ID     SERVICE_NAME
      2018-08-13r0  myapp.appspot.com
      

      在 app.yaml 中

      ENDPOINTS_SERVICE_VERSION: 2018-08-13r0
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-09-18
        • 2019-10-12
        • 2019-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多