Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Channel - Redis integration error : aioredis.errors.ReplyError: ERR unknown command 'EVAL'

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. enter image description here

like image 275
Anoop K George Avatar asked Jul 27 '20 11:07

Anoop K George


1 Answers

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

like image 50
Gabriel Avatar answered Nov 15 '22 03:11

Gabriel