django 频道私聊

我正在使用 Django 频道创建一个 Django 私人聊天应用程序。我正面临 Redis 的问题。有人告诉我 Windows 操作系统不支持 Redis。任何人都可以有替代品吗?


settings.py 通道层


CHANNEL_LAYERS = {

    "default": {

        "BACKEND": "channels_redis.core.RedisChannelLayer",

        "CONFIG": {

            "hosts": [("localhost", 6379)],

        },

    },

}

显示的错误是


connected {'type': 'websocket.connect'}

WebSocket CONNECT /chat/abdullah/ [127.0.0.1:55869]

Exception inside application: ERR unknown command 'EVAL'

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels\sessions.py", line 183, in __call__

    return await self.inner(receive, self.send)

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels\middleware.py", line 41, in coroutine_call

    await inner_instance(receive, send)

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels\consumer.py", line 59, in __call__

    [receive, self.channel_receive], self.dispatch

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels\utils.py", line 59, in await_many_dispatch

    await task

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels\utils.py", line 51, in await_many_dispatch

    result = task.result()

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels_redis\core.py", line 429, in receive

    real_channel

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels_redis\core.py", line 484, in receive_single

    index, channel_key, timeout=self.brpop_timeout

  File "C:\Users\Unknown\PycharmProjects\online_forum\venv\lib\site-packages\channels_redis\core.py", line 327, in _brpop_with_clean

    await connection.eval(cleanup_script, keys=[], args=[channel, backup_queue])

  ERR unknown command 'EVAL'

WebSocket DISCONNECT /chat/abdullah/ [127.0.0.1:55869]


波斯汪
浏览 107回答 2
2回答

猛跑小猪

您可以下载适用于 Windows 的 ubuntu,而不是从 ubuntu 终端运行 redis 服务器 - 效果很好。

三国纷争

您可以在 Windows 上使用In Memory Channel Layer 进行开发。虽然不鼓励在生产中使用。CHANNEL_LAYERS = {    'default': {         "BACKEND": "channels.layers.InMemoryChannelLayer"    },}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python