【问题标题】:aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN' When trying to use redisaioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN' 尝试使用 redis 时
【发布时间】:2020-08-26 06:57:25
【问题描述】:

我有 redis 5.4。我得到这个错误: aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN' 我正在关注 django-channels 网站上的教程。 这是消费者代码:

class ChatConsumer(WebsocketConsumer):
    def connect(self):
        self.room_name = self.scope['url_route']['kwargs']['room_name']
        self.room_group_name = 'chat_%s' % self.room_name

        # Join room group
        async_to_sync(self.channel_layer.group_add)(
            self.room_group_name,
            self.channel_name
        )

        self.accept()

    def disconnect(self, close_code):
        # Leave room group
        async_to_sync(self.channel_layer.group_discard)(
            self.room_group_name,
            self.channel_name
        )

    # Receive message from WebSocket
    def receive(self, text_data):
        text_data_json = json.loads(text_data)
        message = text_data_json['message']

        # Send message to room group
        async_to_sync(self.channel_layer.group_send)(
            self.room_group_name,
            {
                'type': 'chat_message',
                'message': message
            }
        )

    # Receive message from room group
    def chat_message(self, event):
        message = event['message']

        # Send message to WebSocket
        self.send(text_data=json.dumps({
            'message': message
        }))

我使用python manage.py runserver 0.0.0.0:8080 -- noreload 运行我的服务器,也许它与此有关,我在 5656 端口上打开页面,它托管在 8080 上,因为我正在使用 vagrant,这些是 VagrantFile 中的设置端口。

编辑 不知道为什么,但如果我在 pip freeze 检查 redis-server 的版本,我会得到 (.venv) vagrant@vagrant:/vagrant/ChatApp$ redis-server --version Redis 服务器 v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=9435c3c2879311f3,但我不确定这是为什么以及如何解决。

pip feeeze 的输出:

aioredis==1.3.1
asgiref==3.2.10
async-timeout==3.0.1
attrs==20.1.0
autobahn==20.7.1
Automat==20.2.0
certifi==2020.6.20
cffi==1.14.2
channels==2.4.0
channels-redis==3.0.1
chardet==3.0.4
constantly==15.1.0
cryptography==3.0
daphne==2.5.0
Django==3.1
django-channels==0.7.0
hiredis==1.1.0
hyperlink==20.0.1
idna==2.10
incremental==17.5.0
msgpack==1.0.0
oauthlib==3.1.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
pytz==2020.1
redis-server==5.0.7
requests==2.24.0
requests-oauthlib==1.3.0
service-identity==18.1.0
six==1.15.0
sqlparse==0.3.1
Twisted==20.3.0
txaio==20.4.1
urllib3==1.25.10
zope.interface==5.1.0

【问题讨论】:

  • 我有 redis-server 5.0.7。正如您在 pip freeze 中看到的那样安装了,但是从 redis-server --version 命令您可以看到它在那里显示了一个不同的旧版本,我不确定如何让它使用新版本。
  • 我认为您需要删除旧版本才能使其与 v5 一起使用,但您可能需要用谷歌搜索它(不熟悉那些东西)
  • 不确定如何,cpuldnt 找到 4.0.9。在文件系统中,但会尝试
  • redis 服务器不是 pip 包,而是系统包(RPM、DEB 等),因此您不应该在 pip 上查找版本。我不确定您的 pip 上的 redis-server packge 是什么,但它不是所需的服务器。所以你应该忽略它并将系统 redis 服务器更新到版本 5

标签: django redis django-channels redis-server


【解决方案1】:

我不确定,但问题可能与channels-redis有关,可能与channels的版本不兼容,尝试降级或更新channels-redis

【讨论】:

  • 请给出一个确定的答案,不要使用可能,我不确定。只需说明问题与 channel-redis 有关 ...
猜你喜欢
  • 1970-01-01
  • 2020-10-28
  • 2011-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-10
  • 1970-01-01
  • 2021-04-30
相关资源
最近更新 更多