简体   繁体   中英

django channels private chat

I am creating a Django private chat application using Django channels. I am facing a problem with Redis. someone told me that Redis is not supported in Windows OS. Can anyone have an alternate?

settings.py Channel_layer

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

and error shown is

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]

You can download ubuntu for windows, than run redis server from ubuntu terminal - works well.

You can use In Memory Channel Layer for development on windows.

Though is not encouraged for use in production.

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

You can find the download link here https://github.com/MicrosoftArchive/redis/releases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM