django / channels_redis

Redis channel layer backend for Django Channels
BSD 3-Clause "New" or "Revised" License
591 stars 196 forks source link

'Redis' object has no attribute 'bzpopmin' #203

Closed kmahelona closed 4 years ago

kmahelona commented 4 years ago

I came across this error with the latest channels_redis==3.0.0

Error Log

2020-07-06 10:53:59,820 ERROR    Exception inside application: 'Redis' object has no attribute 'bzpopmin'
Traceback (most recent call last):
  File "/webapp/lib/python3.7/site-packages/channels/sessions.py", line 183, in __call__
    return await self.inner(receive, self.send)
  File "/webapp/lib/python3.7/site-packages/channels/middleware.py", line 41, in coroutine_call
    await inner_instance(receive, send)
  File "/webapp/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__
    [receive, self.channel_receive], self.dispatch
  File "/webapp/lib/python3.7/site-packages/channels/utils.py", line 58, in await_many_dispatch
    await task
  File "/webapp/lib/python3.7/site-packages/channels/utils.py", line 50, in await_many_dispatch
    result = task.result()
  File "/webapp/lib/python3.7/site-packages/channels_redis/core.py", line 453, in receive
    real_channel
  File "/webapp/lib/python3.7/site-packages/channels_redis/core.py", line 508, in receive_single
    index, channel_key, timeout=self.brpop_timeout
  File "/webapp/lib/python3.7/site-packages/channels_redis/core.py", line 345, in _brpop_with_clean
    result = await connection.bzpopmin(channel, timeout=timeout)
AttributeError: 'Redis' object has no attribute 'bzpopmin'

pip freeze I've redacted what I think isn't necessary

aioredis==1.2.0
amqp==2.6.0
asgiref==3.2.3
asn1crypto==0.24.0
async-timeout==3.0.1
attrs==19.3.0
cachetools==3.1.0
celery==4.4.6
channels==2.4.0
channels-redis==3.0.0
cryptography==2.9.2
daphne==2.5.0
defusedxml==0.5.0
Django==2.2.6
django-celery-beat==2.0.0
django-ses==1.0.1
future==0.18.2
gunicorn==20.0.4
h2==3.0.1
hiredis==0.3.0
hpack==3.0.0
oauthlib==2.1.0
psycopg2==2.8.5
pycrypto==2.6.1
pyOpenSSL==19.1.0
python-memcached==1.59
pytz==2020.1
requests==2.24.0
requests-oauthlib==1.0.0
Twisted==20.3.0

Fix Setting channels-redis==2.4.2 fixes the problem. I checked that channels is at the latest version and it is.

settings.py These are my settings. Possibly when channels_redis==3.0.0 there's another package that needs to be updated but only Django (and a few other non-related packages) is help back in my settings

Django==2.2.6
# Websockets
channels
pyopenssl
daphne
channels_redis==2.4.2
Twisted[tls,http2]

OS etc.

imran-iq commented 4 years ago

Same thing is happening with us after upgrading to 3.0.0

carltongibson commented 4 years ago

What’s your Redis version? (Less than v5 is EOL according to Redis’ support policy)

imran-iq commented 4 years ago

Looks like we have version 3.2.4 in aws, that is most likely the culprit seeing as bzpopmin is introduced in 5.0

(resolves my issue not sure about the OP)

Si1veR123 commented 4 years ago

Having this issue too. I have redis-server version 4.09. bzpopmin is introduced in 5, however redis_channels states that above 2.?.? works. This is the error: aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'

carltongibson commented 4 years ago

Updated Readme in #204. Thanks all.

kmahelona commented 4 years ago

Ah sorry, I didn't think I installed redis then assumed django-channels did it for me 😅. So the preferred fix here is to upgrade the supported version of redis. Happy to close this if that's valid.

Si1veR123 commented 4 years ago

Ah sorry, I didn't think I installed redis then assumed django-channels did it for me 😅. So the preferred fix here is to upgrade the supported version of redis. Happy to close this if that's valid.

Only cost me about 4 hours of time😂

rarenatoe commented 4 years ago

How did you guys fix this? How did you manage to install version 5 or 6? I only found this and this. Both of them don't go past 3.5

I changed to redis3 but still no luck.

imran-iq commented 4 years ago

@rarenatoe its not your redis client version that needs to be updated, but your redis server version (where ever it is hosted)

(assuming you have redis-cli setup to connect to your redis host)

redis-cli INFO | grep version
redis_version:6.0.8  # <--- this needs to be 5.0 or higher
Si1veR123 commented 4 years ago

How did you guys fix this? How did you manage to install version 5 or 6? I only found this and this. Both of them don't go past 3.5

I changed to redis3 but still no luck.

I just downgraded redis channels to something like 2.4 and kept my redis server and it worked fine Edit: I used 2.4.1 and it worked without error

rarenatoe commented 4 years ago

Thanks guys. I figured it out shortly after. I had to go to AWS and update it there.

adambyer commented 3 years ago

This is still happening for me.

Any ideas what I'm missing?

Si1veR123 commented 3 years ago

This is still happening for me.

  • Redis version=6.2.0
  • redis (lib)==3.5.3
  • channels==3.0.3
  • channels-redis==3.2.0
  • Python 3.9.2
  • macOS 10.15.7

Any ideas what I'm missing?

I dont know if this will help, but I had to use 2.4.1 on channels redis for it to work.

adambyer commented 3 years ago

Thanks @Si1veR123. But that seems to conflict with channels 3 then so I can't upgrade.

Can someone confirm what the appropriate solution is for this? I have everything updated but can't get past this error.

Also the readme says This package is for Channels 2 projects only.. Is that accurate or is channels_redis 3 supposed to work with channels 3?

Thanks.

adambyer commented 3 years ago

Ok looks like upgrading aioredis to the latest has fixed it for me.

ht21992 commented 6 months ago

I had the same issue for my Django project while using channels_redis and I just changed the CHANNEL_LAYERS inside settings.py

from

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}

to

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.pubsub.RedisPubSubChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}
sahelimohammad commented 4 months ago

I had the same issue for my Django project while using channels_redis and I just changed the CHANNEL_LAYERS inside settings.py

from

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}

to

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.pubsub.RedisPubSubChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}

Thank you so much, this solved my problem for 'bzpopmin'