#ASGI deploy

2 messages · Page 1 of 1 (latest)

hard barn
#

Hey I'm running in to issues with deploying my django app locally with use of uvicorn. I got websocket and normal http api in it here are settings:
asgi.py

"""
ASGI config for streamx project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

from channels.security.websocket import AllowedHostsOriginValidator
from channels.routing import ProtocolTypeRouter, URLRouter
from chat import routing
from chat.middleware import JwtAuthMiddlewareStack

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "streamx.settings")

application = ProtocolTypeRouter(
    {
        "http": get_asgi_application(),
        "websocket": AllowedHostsOriginValidator(
            JwtAuthMiddlewareStack(URLRouter(routing.websocket_urlpatterns))
        ),
    }
)

my wsgi.py is normal,
i tried to run it with uvicorn streamx.asgi:application, but it does return error Apps aren't loaded yet.
While running it with uvicorn streamx.wsgi:application, it does run normally (but it's of course not what I want to use), however when i request i still get WSGIHandler.__call__() missing 1 required positional argument: 'start_response' even with using wsgi. I got no idea what's wrong..

#

I use Uvicorn on local, on render.com i will use gunicorn if that does change anything. But for now i want to fix everything on local ofc