“ xread块0流mystream $”,但redis.exceptions.ConnectionError

时间:2019-05-14 06:56:32

标签: redis

我想我需要更改默认的redis配置,但是我不知道需要更改哪些配置参数。

我没有更改默认的redis配置参数。我想使用xread block 0 streams k $来阻止并等待新消息的到来,但这会引发异常。

from redis import Redis


db = Redis(host='192.168.1.24', port=32111, db=0)
print(db.keys('*'))
print(db.config_get('*'))
k = db.execute_command('xread block 0 streams k $')

期望xread block 0 streams k将永久阻止,直到收到新消息为止。 实际错误消息:

Traceback (most recent call last):
  File "/home/server/.local/lib/python3.5/site-packages/redis/connection.py", line 398, in read_response
    raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
OSError: Connection closed by server.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/server/PycharmProjects/test/stream_test.py", line 7, in <module>
    k = db.execute_command('xread block 0 streams k $')
  File "/home/server/.local/lib/python3.5/site-packages/redis/client.py", line 775, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/home/server/.local/lib/python3.5/site-packages/redis/client.py", line 789, in parse_response
    response = connection.read_response()
  File "/home/server/.local/lib/python3.5/site-packages/redis/connection.py", line 637, in read_response
    response = self._parser.read_response()
  File "/home/server/.local/lib/python3.5/site-packages/redis/connection.py", line 409, in read_response
    (e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: ('Connection closed by server.',)

0 个答案:

没有答案