RQ Redis:成功连接后,连接被拒绝

时间:2018-09-09 22:02:40

标签: redis passwords connection python-rq

我的Redis服务器在ubuntu 16.04下运行,我正在运行RQ仪表板来监视队列。 Redis服务器具有我用于初始连接的密码。这是我的代码:

from rq import Queue, Connection, Worker
from redis import Redis
from dblogger import DbLogger

def _redisCon():
    redis_host = "192.168.1.169"
    redis_port = "6379"
    redis_password = "SecretPassword"
    return Redis(host=redis_host, port=redis_port, password=redis_password)

rcon = _redisCon()
if rcon is not None:
    with Connection(rcon):  
        DbLogger.log("rqworker", 0, "Launching Worker", "launching an RQ Worker - default Queue")
        worker = Worker(list(map(Queue, 'default'))) # this works - I see the worker registered in RQ dashboard
        worker.work()  # this eventually fails with the Connection error: 

"""
16:28:49 RQ worker 'rq:worker:steve-imac.95379' started, version 0.12.0
16:28:49 *** Listening on default...
16:28:49 Cleaning registries for queue: default
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 177, in _read_from_socket
    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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/client.py", line 668, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/client.py", line 680, in parse_response
    response = connection.read_response()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 624, in read_response
    response = self._parser.read_response()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 284, in read_response
    response = self._buffer.readline()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 216, in readline
    self._read_from_socket()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 191, in _read_from_socket
    (e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: ('Connection closed by server.',)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/redis/connection.py", line 489, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 61 connecting to 192.168.1.169:6379. Connection refused.
"""

我尝试过删除密码并在redis.conf中启用unixsocket-似乎都没有帮助。这似乎是在某种超时中发生的,因为在其他测试中,工作人员实际上加载了任务并执行了该任务,然后最终死于该错误。

0 个答案:

没有答案