2017-10-13 82 views
0

我在通過資源管理器'_ah/api/explorer'訪問api時,或者在從應用程序調用API時,出現了以下錯誤。調用雲框架端點api時出錯

下面是來自app.yaml和api實現的相關部分。

從stackoverflow上的其他問題看起來像這可能發生,如果端點配置不使用gcloud服務管理部署,但事件後上傳gatewayv1openapi.json我收到類似的錯誤。

有什麼我需要改變在API代碼或app.yaml?還有一件事是,我已經上傳了完全相同的代碼庫(只有不同​​的是其他項目ID,而不是app.yaml中的ixp-test)到另一箇舊項目,它工作正常。任何新創建的項目都會出現此錯誤。

/_ah/API /網關/ V1 /調用?ALT = JSON

沒有調度線程,scheduler.run()會報告(...)被調用(/基/數據/家/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/client.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 /版本/ 1/google/appengine/api/background_thread/background_thread.py「,lin e 108,開始 start_new_background_thread(self。 自舉,()) 文件 「/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 FrontendsNotSupported 。 。 。 (/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263) 回溯(最近通話最後): 文件「/ base/data/home /運行時/ python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py「,第240行,在Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) 文件」/ base/data/home//python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py「,第299行,在_LoadHandler handler,path,err = LoadObject(self._handler) 文件」/ base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py「,第96行,在LoadObject中 __import(cumulative_path) 文件「/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-測試/ 20171013t215957.404774686885375478/server/lib/endpoints_management/control/wsgi.py「,第126行,在add_all中 a_service = loader.load() 文件」/ base/data/home/apps/s〜ixp-test/「/ base/data/home/apps/s〜ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/service.py」,第111行,載入中 return self._load_func(** kw) 「 20171013t215957.404774686885375478 /服務器/ lib中/ endpoints_management/CON在/etc/home/apps/s_ixp-test/ 20171013t215957文件「/ fig/service_config.py」中,第79行,在fetch_service_config中 _log_and_raise(Exception,message_template.format(status_code)) 。404774686885375478 /服務器/ lib中/ endpoints_management /配置/ service_config.py」,第127行,在_log_and_raise 提高exception_class(消息) 例外:正在獲取服務配置失敗(狀態代碼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 

回答

1

如果gatewayv1openapi.json中的服務名稱與app.yaml中的服務名稱不匹配,可能會發生這種情況;你可以仔細檢查一下嗎?

+0

是它們匹配。 – rizTaak

0

管理解決它。問題是由於未更新

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]