Redis ERR unknown command 'BZPOPMIN'
Asked Answered
S

11

20

I installed Redis version 4.0.9 in a Ubuntu Linux Subsystem on Windows 10 by following these instructions (i.e. sudo apt-get install redis-server).

I am following this tutorial on Django channels, and I ran the following code:

>>> 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')

When the last line above is executed, I get this error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line 120, in __call__
    return call_result.result()
  File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 425, in result
    return self.__get_result()
  File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 384, in __get_result
    raise self._exception
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line 180, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 485, in receive
    return (await self.receive_single(channel))[1]
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 508, in receive_single
    index, channel_key, timeout=self.brpop_timeout
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 345, in _brpop_with_clean
    result = await connection.bzpopmin(channel, timeout=timeout)
aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'

On this page, someone suggested using Redis version 5. How do I install Redis version 5 on Windows 10? Any other ideas on how to solve this issue?

Scummy answered 8/7, 2020 at 3:14 Comment(2)
Rune Kaagaard posted an Answer saying "On ubuntu 16.04 use this ppa: launchpad.net/~chris-lea/+archive/ubuntu/redis-server"Bulb
I'm using WSL as well, and the problem wasn't windows but the redis version I was using on my packages as stated by @MarvinCorreiaOsswald
O
9

There is no official support for Redis in Windows OS.

However, Microsoft develops and maintains microsoftarchive/redis. Also it is no longer supported (older versions are availble). I had long search on this about installing version 5 in windows 10. But no luck.

Better you can go for Memurai. Memurai is 100% compatible with the Redis protocol (also supported version 5 too). It is free for development and testing.

EDIT : From Itamar comment, u can also use this as alternative for Memurai

Overbuild answered 8/7, 2020 at 4:18 Comment(3)
I don't think github.com/tporadowski/redis is closer to Redis than Memurai is. They both derive from the (now abandoned) MS Open Tech port, and Memurai was the first to have Redis 5.x compatibility. Memurai also supports the BZPOPMIN command.Clearly
Installing Memurai has fixed my problem. Thanks!Scummy
An alternative OSS project is github.com/tporadowski/redis. I'm now aware that Memurai supports BZPOPMIN.Aspic
G
50

I think the problem is in the compatibility with version of the channels-redis package! I had already tested channels some time ago and it worked beautifully with channels-redis version 2.4.2, recently they are in version 3.0.1 and this version doesn't work properly yet I don't know why.

Try install the version 2.4.2 with pip:

pip install channels-redis==2.4.2
Grassplot answered 20/8, 2020 at 20:20 Comment(1)
just update the redis server, it will fix the issue.Vd
R
15

Use redis 5.0.9. It worked for for the same error.

Get it from github.com/tporadowski/redis/releases

Reductase answered 9/8, 2020 at 6:24 Comment(0)
C
11

Just download the latest version of Redis for Windows https://github.com/tporadowski/redis/releases from here it will work.

you don't need to downgrade the version of your channels-redis etc. This problem with Redis not with any python packages at all.

Chime answered 3/12, 2020 at 12:44 Comment(4)
Does it only support 64 -bit? I needed for 32-bit, no clue where to get one. I'm also using windows 7 which makes it worse to find.Nictitate
@Nictitate look at this. #57536512 and install the same redis that I have given the linkChime
I tried installing but it's saying 64 bit is not supported.Nictitate
@Nictitate you must update to window 10 then it will definitely workChime
S
10

You need to install the latest version(6+) of redis:

$ sudo add-apt-repository ppa:redislabs/redis
$ sudo apt-get update
$ sudo apt-get install redis

then restart the redis-server.

Subpoena answered 28/4, 2021 at 4:55 Comment(1)
This should be accepted answer as it allows latest versions of channels and channels-redisLucent
O
9

There is no official support for Redis in Windows OS.

However, Microsoft develops and maintains microsoftarchive/redis. Also it is no longer supported (older versions are availble). I had long search on this about installing version 5 in windows 10. But no luck.

Better you can go for Memurai. Memurai is 100% compatible with the Redis protocol (also supported version 5 too). It is free for development and testing.

EDIT : From Itamar comment, u can also use this as alternative for Memurai

Overbuild answered 8/7, 2020 at 4:18 Comment(3)
I don't think github.com/tporadowski/redis is closer to Redis than Memurai is. They both derive from the (now abandoned) MS Open Tech port, and Memurai was the first to have Redis 5.x compatibility. Memurai also supports the BZPOPMIN command.Clearly
Installing Memurai has fixed my problem. Thanks!Scummy
An alternative OSS project is github.com/tporadowski/redis. I'm now aware that Memurai supports BZPOPMIN.Aspic
L
2

This is how i resolve this issue. Ubuntu 18 installs redis 4 but ubuntu 20 installs redis 5. You can find your redis version by typing redis-cli -v. So i uninstall ubuntu 18 from my windows subsystem for linux (WSL) and reinstall ubuntu 20. It worked just fine.

Laural answered 16/7, 2020 at 4:58 Comment(0)
S
2

Same problem on Ubuntu 16.04

Similarly, I was following the chat application tutorial on Django Channels website and had the same error:

aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'

The problem occurred when I used these versions:

redis-server==3.0.6
channels==3.0.3
channels-redis==3.2.0

Thanks to @marvin-correia for his answer I figured out the problem's reason is the version of the channels-redis package! So as he suggested, I installed channel-redis version 2.4.2 and the error has gone.

pip install channels-redis==2.4.2

Also, I've to note that channels package downgraded to channels==2.4.0 automatically.

Sluff answered 28/4, 2021 at 7:7 Comment(0)
A
0

Problem is with the version. Try older one I found "2,3,4" any version with it stable and properly working. https://github.com/tporadowski/redis/releases

Anamorphoscope answered 29/8, 2020 at 13:58 Comment(0)
V
0

To add to @Marvin answer, for me it was similar (some versioning problem probably), I reinstalled django_channels and django to the exact version as specified in the tutorial (3.0, 2.2) and it worked. Not sure what exactly worked but recommend checking it:)

Visigoth answered 14/2, 2021 at 13:47 Comment(0)
C
0

I will also confirm Marvins answer. Hopefully this will help someone out but also leaving this here for notes.

Development:

(this setup works) considering data is sent to and form http://localhost:8000

Setup

Windows 10 Running WSL with Ubuntu 20.04

  • Python==3.10
  • Django==4.0
  • Redis==5.0.7
  • channels-redis==3.3.1

Production

setup

  • Python==3.8
  • Ubuntu==16.04
  • Redis-server==3.0.6
  • chanels-redis==2.4.2
  • channels==3.0.3

When I downgraded, channels-redis, it automcatically downgraded channels as well. Then you can force the upgrade to channels==3.0.3, but it will raise an incompatibility error. Also, if 2 files will most likely to be updated to run Django 4.0

1 being here https://github.com/django/channels/issues/1609

Chauncey answered 23/1, 2022 at 23:20 Comment(0)
K
0

I was getting this error on a Windows machine, I would suggest you to use Redis on a docker image instead of using Redis server on a windows machine.

One of the way to run a redis server via a docker image and map the port 6379 is to:

  1. start docker desktop

  2. In your terminal type the below command.

    docker run -p 6379:6379 -d redis:5

Kinnikinnick answered 20/2, 2022 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.