dockergoogle-app-engineapp-engine-ndbgoogle-cloud-sdkdev-appserver

Devappserver: Attempted RPC call without active security ticket


We're in the migration process from webapp2 to the latest version of Django. We want to keep using legacy services like Appengine NDB for now before we move to the latest technologies.

For running the development environment locally I am using devappserver inside a docker environment because devappserver doesn't work with python3 according to Google.

My Google Cloud SDK version inside docker container is: 424.0.0

The server runs, but I keep getting this error whenever I try to access a View that uses some sort of legacy service:

google.appengine.runtime.apiproxy_errors.RPCFailedError: Attempted RPC call without active security ticket

Error log: docker error logs

The app.yaml (for deployment looks like this):

runtime: python38
instance_class: F2
app_engine_apis: 'True'

entrypoint: bash -c 'python3 manage.py migrate --settings=conf.settings.dev --noinput && gunicorn -b :$PORT main:app'

handlers:
- url: /static
  static_dir: static/

- url: /.*
  script: auto
  secure: always
  redirect_http_response_code: 301

builtins:
  - deferred: on


env_variables:
  DEBUG: 'False'
  DB_HOST: 
  DB_PORT:
  DB_NAME: 
  DB_USER: 
  DB_PASSWORD: 
  DJANGO_SETTINGS_MODULE: conf.settings.dev

main.py:

from conf.wsgi import application
from google.appengine.api import wrap_wsgi_app

app = wrap_wsgi_app(application, use_legacy_context_mode=True, use_deferred=False)

The django app works as expected when deployed to AppEngine Standard Environment. There is no error when running services inside the docker containers locally.

The package that I'm using for app engine bundled legacy service: Legacy Bundled Services

Example view:

from django.views import View
from django.http import JsonResponse

from google.appengine.api import memcache

class UserView(View):
    def get(self, request):
        memcache.set("Globe", "Jupiter")
        return JsonResponse({'hello': memcache.get("Globe")})

I have tried these approaches and failed to resolve the error:


Solution

  • devappserver doesn't work with python3 according to Google.

    From the above, I assume you're running on Windows. If so, we have a patch that swaps out Gunicorn (since by default it doesn't work on windows and is what dev_appserver.py uses) for Waitress when you run with dev_appserver.py on your local environment (see this post on Google Cloud Community)

    You can then run your App locally without having to use docker containers and it works with the Bundled APIs.