通道层和Redis之间的通信错误

时间:2020-07-22 06:31:38

标签: python django redis communication

我在Linux中安装了Redis版本6.0.6

我正在Django频道上关注本教程,并且运行了以下代码:

>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel',{'type':'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel')

我得到了这样的错误

 Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/peacekim/chat/venv/lib/python3.6/site-packages/asgiref/sync.py", line 139, in __call__
    return call_result.result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/peacekim/chat/venv/lib/python3.6/site-packages/asgiref/sync.py", line 204, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "/home/peacekim/chat/venv/lib/python3.6/site-packages/channels_redis/core.py", line 485, in receive
    return (await self.receive_single(channel))[1]
  File "/home/peacekim/chat/venv/lib/python3.6/site-packages/channels_redis/core.py", line 508, in receive_single
    index, channel_key, timeout=self.brpop_timeout
  File "/home/peacekim/chat/venv/lib/python3.6/site-packages/channels_redis/core.py", line 345, in _brpop_with_clean
    result = await connection.bzpopmin(channel, timeout=timeout)
aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'

如何解决此错误。请...

0 个答案:

没有答案