diff --git a/chris_backend/config/asgi.py b/chris_backend/config/asgi.py index a909fe40..a4c114a3 100755 --- a/chris_backend/config/asgi.py +++ b/chris_backend/config/asgi.py @@ -10,17 +10,20 @@ import os, sys sys.path.append(os.path.dirname(os.path.dirname(__file__))) +# get_asgi_application MUST be called before other imports. +# https://github.com/django/channels/issues/1564#issuecomment-722354397 +from django.core.asgi import get_asgi_application +django_asgi_app = get_asgi_application() + from core.websockets.urls import websocket_urlpatterns from core.websockets.auth import TokenQsAuthMiddleware from channels.routing import ProtocolTypeRouter, URLRouter -from django.core.asgi import get_asgi_application from channels.security.websocket import AllowedHostsOriginValidator os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.production') -django_asgi_app = get_asgi_application() # see https://channels.readthedocs.io/en/3.x/installation.html application = ProtocolTypeRouter({