5

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

7
  • Eval is available since Redis 2.6. Redis 2.4 is close to 10 years old - it's kind of expected that modern frameworks have moved away from an unsupported platform and unsupported release. Commented Jul 27, 2020 at 11:17
  • Thank you, Do you have any reference for Redis 2.6 repo ? Commented Jul 27, 2020 at 11:18
  • Downloaded Redis 2.4 from (sourceforge.net/projects/redis) : but got new errorm ,aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'. Commented Jul 27, 2020 at 11:28
  • @Melvyn Can I run Channels without Redis ? Commented Jul 27, 2020 at 11:29
  • 2
    github.com/django/channels_redis#dependencies -> Redis >= 5.0. You can run channels with an another layers backend but the tutorial uses redis. Commented Jul 27, 2020 at 11:35

1 Answer 1

11

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

Sign up to request clarification or add additional context in comments.

5 Comments

hey! thanks a lot.. I was also facing the same challenge for a long time.. and most of the time its just such trivial things!
Thanks so much dude, i have been trubleshooting this since morning before i came across your solution. Thanks a bunch
hey, I changed the layer settings earlier to InMemoryChannelLayer and it was working fine until recently. And I came across this documentation which says not to use In memory config in production. So I'm back to EVAL error. Any other possible solution?
This is basically a non-solution given that InMemoryChannelLayer does not work for most production setups (i.e. any setup with more than a single server thread)
InMemoryChannelLayer is good for development purposes. i can't get redis channel layer to work at the moment, so I will use it. but ultimately needs to be switched to redis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.