hello I am working on chatting app with django channels works perfectly in localhost but once I used redis and deployed to heroku I can't send anymessage the websocket always close, my settings.py
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
},
},
}
I am using redis and postgresql addons, and my Procfile is like this
web: daphne myproject.asgi:application --port $PORT --bind 0.0.0.0 -v2
worker: python manage.py runworker --settings=myproject.settings -v2
the error from heroku logs --tail
2022-01-07T23:33:49.877754+00:00 app[web.1]: raise InvalidChannelLayerError(
2022-01-07T23:33:49.877754+00:00 app[web.1]: channels.exceptions.InvalidChannelLayerError: ROUT
ING key found for default - this is no longer needed in Channels 2.
2022-01-07T23:33:49.877914+00:00 app[web.1]: 2022-01-07 23:33:49,877 INFO failing WebSocket
opening handshake ('Internal server error')
2022-01-07T23:33:49.878083+00:00 app[web.1]: 2022-01-07 23:33:49,878 WARNING dropping connecti
on to peer tcp4:10.1.83.62:25575 with abort=False: Internal server error
2022-01-07T23:33:49.878720+00:00 app[web.1]: 2022-01-07 23:33:49,878 DEBUG WebSocket closed
for ['10.1.83.62', 25575]
why it works perfectly in my localhost because I am using only this
CHANNEL_LAYERS = {
"default": {
"BACKEND": 'channels.layers.InMemoryChannelLayer'
}
}