3

I have a problem configuring Endpoints API. Any code i use, from my own, to google's examples on site fail with the same traceback

WARNING  2016-11-01 06:16:48,279 client.py:229] no scheduler thread, scheduler.run() will be invoked by report(...)
Traceback (most recent call last):
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/client.py", line 225, in start
self._thread.start()
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 108, in start
start_new_background_thread(self.__bootstrap, ())
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 87, in start_new_background_thread
raise ERROR_MAP[error.application_error](error.error_detail)
FrontendsNotSupported
INFO     2016-11-01 06:16:48,280 client.py:327] created a scheduler to control flushing
INFO     2016-11-01 06:16:48,280 client.py:330] scheduling initial check and flush
INFO     2016-11-01 06:16:48,288 client.py:804] Refreshing access_token
/home/vladimir/projects/sb_fork/sb/lib/vendor/urllib3/contrib/appengine.py:113: AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/contrib.html.
AppEnginePlatformWarning)
ERROR    2016-11-01 06:16:49,895 service_config.py:125] Fetching service config failed (status code 403)
ERROR    2016-11-01 06:16:49,896 wsgi.py:263] 
Traceback (most recent call last):
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/vladimir/projects/sb_fork/sb/main.py", line 27, in <module>
api_app = endpoints.api_server([SolarisAPI,], restricted=False)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/endpoints/apiserving.py", line 497, in api_server
controller)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/wsgi.py", line 77, in add_all
a_service = loader.load()
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/service.py", line 110, in load
return self._load_func(**kw)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 78, in fetch_service_config
_log_and_raise(Exception, message_template.format(status_code))
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 126, in _log_and_raise
raise exception_class(message)
Exception: Fetching service config failed (status code 403)
INFO     2016-11-01 06:16:49,913 module.py:788] default: "GET / HTTP/1.1" 500 -

My app.yaml is configured like the new Endpoints Migrating to 2.0 document states:

- url: /_ah/api/.*
  script: api.solaris.api_app

And main.py imports the API into the app:

api_app = endpoints.api_server([SolarisAPI,], restricted=False)

I use Google Cloud SDK with these versions:

Google Cloud SDK 132.0.0
app-engine-python 1.9.40
bq 2.0.24
bq-nix 2.0.24
core 2016.10.24
core-nix 2016.10.24
gcloud 
gsutil 4.22
gsutil-nix 4.22
dgmt
  • 485
  • 1
  • 3
  • 13

2 Answers2

2

Have you tried generating and uploading the OpenAPI configuration for the service? See the sections named "Generating the OpenAPI configuration file" and "Deploying the OpenAPI configuration file" in the python library documentation.

Note that in step 2 of the generation process, you may need to prepend python to the command (e.g python lib/endpoints/endpointscfg.py get_swagger_spec ...), since the PyPi package doesn't preserve executable file permissions right now.

tutuDajuju
  • 10,307
  • 6
  • 65
  • 88
  • that is the missing step, i am having the same problems with the environment like in this issue, and i can't seem to resolve the appengine.ext [issue](http://stackoverflow.com/questions/39926853/error-running-endpointscfg-py-get-swagger-spec) – dgmt Nov 04 '16 at 23:09
  • 1
    @Brad I am seeing the same error even with the right `env_variables` in app.yaml. Any idea why that could be the case? http://stackoverflow.com/questions/42310672/google-appengine-endpoints-error-fetching-service-config-failed-status-code-40 has more information. – user362953 Feb 18 '17 at 03:28
  • I responded to the question, but copying what I said here -- the `gcloud service-management deploy` step probably didn't work as expected. I would try that again, making sure everything is configured correctly, and making sure there are no errors output in that command. Let me know if that works! :) – Brad Friedman Feb 20 '17 at 22:57
  • @BradFriedman: Thanks :) I have related questions :) I added API to my existing AppEngine WebApp. I only specified a handler "url: /_ah/spi/.*" and added the handler code. I can see my endpoint through API Explorer and it's is working. Among the steps in Quickstart referred in sebi's answer, I didn't implement "Generating the OpenAPI configuration file" or "Deploying the OpenAPI configuration file". This brings me to questions like: By omitting the OpenAPI steps, have I implemented only some steps for using Endpoints. What is Endpoint Service? It seems I haven't used Service. – user362953 Feb 22 '17 at 20:13
1

To get rid of the "FrontendsNotSupported" you need to use a "B*" instance class.

The error "Exception: Fetching service config failed" should be gone if you follow the steps in https://cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python. As already pointed out by Brad, the section "OpenAPI configuration" and the resulting environment variables are required to make the service configuration work.

sebi
  • 46
  • 3
  • 1
    I am not able to follow "you need to use a "B*" instance class." Can you give more information on that? – user362953 Feb 18 '17 at 03:26
  • @user362953 Your service instance in appengine has a class which specifies the class or resources(CPU, Memory) your application need/uses. `https://cloud.google.com/appengine/docs/standard/#instance_classes` you can find everything about that. – Vamsidhar Muggulla Sep 06 '17 at 06:28