我正在尝试将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的新手,无法理解这个错误。有人可以解释一下这个错误是什么以及如何解决它吗?
“主动拒绝”是指客户端的TCP 3次握手 失败并返回 RST(重置)数据包(或者不太可能, 防火墙在管理上禁止返回 ICMP)。
您可以使用
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)
查看本地守护程序正在侦听的端口的列表。
5672 的条目应该来来去去,
根据 RabbitMQ 是否正在运行。