aioredis.errors.ProtocolError:协议错误,得到“H”作为回复类型字节

问题描述

我有一个 Django 项目,我正在尝试实施 Redis 频道。当我添加下面的配置时,我的应用程序就可以工作了。

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels.layers.InMemoryChannelLayer"
    }
}

但是,当我尝试添加以下配置时,出现 aioredis.errors.ProtocolError: Protocol error,got "H" as reply type byte 错误

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

这是我的consumers.py文件

class VideoCallSignalConsumer(AsyncWebsocketConsumer):
    async def connect(self):
        self.room_name = self.scope['url_route']['kwargs']['room_name']
        self.room_group_name = 'Test-Room'
        # print(self.scope["user"])

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

        await self.accept()

顺便说一句,我使用的是 macOS。我已经使用 brew install redis 命令安装了 Redis,并使用 redis-server 命令启动了 daphne -p 6379 VideoConference.asgi:application

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)