Home > Net >  Add Redis USER & PASS to Django channel layer
Add Redis USER & PASS to Django channel layer

Time:08-20

I'm trying to deploy my WebSocket project on the server (for example Heroku). and I have a Redis server that has a USER & PASS. I want to add this to my Django channel layer. I need your help.

This is my channel layer:


 CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'USER': 'spadredis-zxs-service',
        'PASSWORD': '9zghygpri84f8vl',
        'CONFIG': {
            "hosts": [('188.40.16.3', 32281)],
        },
    },
} 


This is my error in terminal :


await conn.execute('ping')
aioredis.errors.AuthError: NOAUTH Authentication required.
WebSocket DISCONNECT /ws/chat/lobby_room/ [127.0.0.1:42812] 

 :)))

CodePudding user response:

I can see that OP is using the channels-redis package in order to use Redis as a channel layer, that's good.

Assuming Redis is running in the host 188.40.16.3 and the port 32281, I suggest OP to remove USER and PASSWORD from CHANNEL_LAYERS and add it in the CONFIG hosts (as suggested here) like

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            "hosts": [("redis://spadredis-zxs-service:[email protected]:32281")],
        },
    },
}
  • Related