1

I'm trying to use channels for a django app.I have installed all the required dependencies (i think). I have listed 'channels' on INSTALLED_APPS of myapp/settings.py.However,I run daphne ( daphne chat.asgi:channel_layer --port 8888)-( no error message on cmd), then when i run python manage.py runworker which gives an Error message that says - "channels.asgi.InvalidChannelLayerError: no BACKEND specified for default". . I'm novice for django, i have asgi.py as

import os
import channels.asgi

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chat.settings")
channel_layer = channels.asgi.get_channel_layer()

But in my myapp/settings.py, i have specified the BACKEND specified for default.Can you please suggest a solution to this error? Here is a probable solution,but the asgi_redis was current in my django1.10. I'm trying to run myapp on my local machine.

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
            #"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],

        },
        "ROUTING": "myproject.myapp.routing.channel_routing",
    },
}
Community
  • 1
  • 1
Kaleab Woldemariam
  • 2,567
  • 4
  • 22
  • 43

1 Answers1

0

Add this to the top of your settings.py

import asgi_redis

Also, make sure that you have installed Redis

pip install asgi_redis
cjds
  • 8,268
  • 10
  • 49
  • 84