Deploying asgi and wsgi on Heroku
channel, django, heroku, python, wsgi
Solution
Figured this out, in case this might be relevant to anyone else. Using just asgi was the best solution. My procfile ended being:
web: daphne chat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2
chatworker: python manage.py runworker --settings=chat.settings -v2
As a solution for serving static files, I updated my routing.py file to include a StaticFileConsumer.
Problem
I'm trying to deploy Django Channels on Heroku using asgi alongside my existing wsgi implementation. Can I deploy both asgi and wsgi to heroku with the following setup? My procfile: ``` web: gunicorn chatbot.wsgi --preload --log-file - daphne: daphne chat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2 chatworker: python manage.py runworker --settings=chat.settings -v2 ``` My asgi.py file: ``` import os from channels.asgi import get_channel_layer os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chat.settings") channel_layer = get_channel_layer() ``` My wsgi.py file: ``` import os from django.core.wsgi import get_wsgi_application from whitenoise.django import DjangoWhiteNoise os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chat.settings") application = get_wsgi_application() application = DjangoWhiteNoise(application) ``` And my channel layers in settings.py: ``` CHANNEL_LAYERS = { 'default': { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')] }, 'ROUTING': 'chat.routing.channel_routing', } } ```