I have deployed my django webapp to my heroku server and it was working fine until I added a websocket connection that shows the contents of a model object in a separate url as soon as that object is created. For this, I used Django channels with a redis server hosted on redislabs. To run asgi app, I tried to use daphne server but when I try to run the daphne server with the following command:
$daphne smartResturant.asgi:channel_layer --port 8888
, it says
"django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet"
My asgi.py
import os
import django
from smartResturant.routing import get_default_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "smartResturant.settings")
django.setup()
application = get_default_application()
My settings.py
ASGI_APPLICATION = 'smartResturant.routing.application'
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": ['redis://:xxxxxxxx@redis-13131.c85.us-east-1-2.ec2.cloud.redislabs.com:13131']
},
},
}
It works fine when I run locally without using daphne server. But I found out that to run asgi based apps on a hosted server, you have to use daphne server and I am unable to run it. Any help will be appreciated!