【问题标题】:Error while calling cloud framework endpoint api调用云框架端点 api 时出错
【发布时间】:2018-03-25 17:15:23
【问题描述】:

通过资源管理器“_ah/api/explorer”访问 api 或从应用程序调用 api 时出现以下错误。

以下是 app.yaml 和 api 实现的相关部分。

从 stackoverflow 上的其他问题来看,如果端点配置未使用 gcloud 服务管理部署,但上传 gatewayv1openapi.json 后的事件,我会收到类似的错误。

我需要在 api 代码或 app.yaml 中更改什么吗?另一件事是我已经将完全相同的代码库(唯一的区别是其他项目 id 而不是 app.yaml 中的 ixp-test)上传到另一个旧项目并且它工作正常。任何新创建的项目都会出现此错误。

/_ah/api/gateway/v1/invoke?alt=json

没有调度线程, scheduler.run() 将被 report(...) 调用 (/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/客户端.py:235) 回溯(最近一次通话最后): 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/client.py”,第 231 行,开始 self._thread.start() 文件“/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/background_thread/background_thread.py”,第 108 行,开始 start_new_background_thread(self.bootstrap, ()) 文件“/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/background_thread/background_thread.py”,第 87 行,在 start_new_background_thread 引发 ERROR_MAPerror.application_error 不支持前端 . . . (/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263) 回溯(最近一次通话最后): Handle 中的文件“/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py”,第 240 行 handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) _LoadHandler 中的文件“/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py”,第 299 行 处理程序,路径,错误 = LoadObject(self._handler) LoadObject 中的文件“/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py”,第 96 行 __import(累积路径) 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/main.py”,第 18 行,在 api = endpoints.api_server([GatewayApi]) 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints/apiserving.py”,第 514 行,在 api_server 控制器) 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/wsgi.py”,第 126 行,在 add_all a_service = loader.load() 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/service.py”,第 111 行,加载中 return self._load_func(**kw) 文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/config/service_config.py”,第 79 行,在 fetch_service_config _log_and_raise(异常,message_template.format(status_code)) _log_and_raise 中的文件“/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/config/service_config.py”,第 127 行 引发异常类(消息) 异常:获取服务配置失败(状态码 403)

下面是相关配置

app.yaml

runtime: python27
api_version: 1
threadsafe: false
automatic_scaling:
  max_idle_instances: 0


env_variables:
  ENDPOINTS_SERVICE_NAME: ixp-test.appspot.com
  ENDPOINTS_SERVICE_VERSION: 2017-08-13r0

API

@endpoints.api(name='gateway', version='v1')
class GatewayApi(remote.Service):
    @endpoints.method(
        GatewayRequest,
        GatewayResponse,
        path='invoke',
        http_method='POST',
        name='invoke')
    def invoke(self, request):
        pass
    @endpoints.method(
        GatewayRequest,
        GatewayResponse,
        path='invokeSecure',
        http_method='POST',
        name='invokeSecure',
        scopes=[endpoints.EMAIL_SCOPE])
    def invoke_secure(self, request):
        pass

【问题讨论】:

    标签: google-app-engine google-cloud-endpoints


    【解决方案1】:

    如果 gatewayv1openapi.json 中的服务名称与 app.yaml 中的服务名称不匹配,这很可能会发生;你能仔细检查一下吗?

    【讨论】:

    • 是的,它们确实匹配。
    【解决方案2】:

    设法解决它。问题是由于没有更新

    ENDPOINTS_SERVICE_VERSION: 2017-08-13r0
    

    对于新项目。来自它正在工作的旧部署项目的值导致了错误。

    来自getting started tutorial

    gcloud service-management deploy echov1openapi.json
    Service Configuration [2017-02-13-r2] uploaded for service [example-project.appspot.com]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2014-05-08
      • 2016-03-12
      • 1970-01-01
      相关资源
      最近更新 更多