I am new to Django channels and following the tutorial ( https://channels.readthedocs.io/en/latest/tutorial/part_2.html)
As Redis does not support Windows 7 I downloaded Redis version 2.4 from (https://github.com/dmajkic/redis/downloads)
When I try to access the Redis from Django shell I got error as mentioned in the subject.
$ python3 manage.py shell
>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel') # ERROR OCCURED AFTER THIS STEP
As you can see below, the Redis folder , it start dev server at port 6379.
I had the same problem following the same tutorial, including a similar and older project that suddenly stopped working ... The following change solved my problem:
Before:
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
'hosts': [('127.0.0.1', 6379)]
},
},
}
Solution:
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels.layers.InMemoryChannelLayer"
}
}
Source: https://channels.readthedocs.io/en/latest/topics/channel_layers.html#in-memory-channel-layer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With