我面对的是一个rabbitmq(无法连接,目标主动拒绝),有人能告诉我为什么会发生这种情况吗

mctunoxg  于 11个月前  发布在  RabbitMQ
关注(0)|答案(1)|浏览(116)

我正在尝试将rabbitmq连接到celery上。

ERROR/MainProcess] consumer: Cannot connect to amqp://local:**@127.0.0.1:5672//: [WinError 10061] No connection could be made because the target machine actively refused it.
Trying again in 32.00 seconds... (16/100)
[2024-01-06 14:32:06,347: CRITICAL/MainProcess] Unrecoverable error: OperationalError('[WinError 10061] No connection could be made because the target machine actively refused it')
Traceback (most recent call last):
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\connection.py", line 472, in _reraise_as_library_errors
    yield
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\connection.py", line 459, in _ensure_connection
    return retry_over_time(
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\utils\functional.py", line 318, in retry_over_time
    return fun(*args, **kwargs)
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\connection.py", line 934, in _connection_factory
    self._connection = self._establish_connection()
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\connection.py", line 860, in _establish_connection
    conn = self.transport.establish_connection()
  File "D:\venvs\mlops_backend_venv\lib\site-packages\kombu\transport\pyamqp.py", line 203, in establish_connection
    conn.connect()
  File "D:\venvs\mlops_backend_venv\lib\site-packages\amqp\connection.py", line 324, in connect
    self.transport.connect()
  File "D:\venvs\mlops_backend_venv\lib\site-packages\amqp\transport.py", line 129, in connect
    self._connect(self.host, self.port, self.connect_timeout)
  File "D:\venvs\mlops_backend_venv\lib\site-packages\amqp\transport.py", line 184, in _connect
    self.sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:\venvs\mlops_backend_venv\lib\site-packages\celery\worker\worker.py", line 202, in start
    self.blueprint.start(self)
  File "D:\venvs\mlops_backend_venv\lib\site-packages\celery\bootsteps.py", line 116, in start
    step.start(parent)
  File "D:\venvs\mlops_backend_venv\lib\site-packages\celery\bootsteps.py", line 365, in start
    return self.obj.start()
  File "D:\venvs\mlops_backend_venv\lib\site-packages\celery\worker\consumer\consumer.py", line 340, in start
    blueprint.start(self)
  File "D:\venvs\mlops_backend_venv\lib\site-packages\celery\bootsteps.py", line 116, in start

字符串
我尝试在rabbitmq管理界面更改权限,检查日志,重新启动rabbitmq服务器,仔细检查用户名,密码,检查端口是否正确和监听,禁用并启用插件。后端创建了所需的交换,但队列没有(只是通知它是否有帮助)。但问题仍然存在。
我是rabbitmq的新手,无法理解这个错误。有人能解释一下这个错误是什么以及如何解决它吗?

zujrkrfu

zujrkrfu1#

“主动拒绝”是指客户端的TCP 3次握手失败,返回了一个重置(reset)数据包(或者更不可能,防火墙在管理上禁止返回)。
您可以使用nc netcat或

telnet 127.0.0.1 5672

字符串
现在你会看到

Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host


一旦你修复了配置,telnet和其他客户端将能够成功连接。所以这是一个快速方便的测试,当你调整配置细节时很方便。在创建网络连接的早期阶段,密码和密码肯定还不相关。
最重要的是让一个守护进程在那个端口上运行和监听。另外,如果你的服务器是,比如说,10.0.0.7,并且守护进程绑定到套接字标识符“10.0.0.7:5672”而不是“127.0.0.1:5672”或等价于IPv4地址,那就糟糕了。
如果你有一个本地防火墙配置,禁止这种连接尝试,这将是糟糕的。曲柄的日志记录级别,并查看其日志。
查看netstat -an的输出(即所有tcp连接,数值ips),查看本地守护进程正在监听的端口列表。根据RabbitMQ服务器是否正在运行,5672条目应该来来去去。

相关问题