无法连接到rabbitmq - ACCESS_REFUSED

vmdwslir  于 2023-08-05  发布在  RabbitMQ
关注(0)|答案(1)|浏览(240)

各位!
我想使用管理员级别的登录名和密码连接到带有aio_pika的rabbitmq。

async def send_rmq(message) -> None:
    connection = await connect("amqp://login:password@url")

字符串
连接时出错:

aiormq.exceptions.ProbableAuthenticationError: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.


我尝试通过web界面和curl命令进行连接:

curl -s -u login:password http://url:15672/api/queues/%2F/name_queue | grep -o '"messages":[0-9]*'


我登录到界面,得到curl命令的实际数值,也就是网络没有问题,正如我所理解的。
会有什么问题呢?
我在一个远程服务器上工作,项目在Docker中运行,Rabbit在另一个服务器上运行,也在Docker中。我从我工作的远程服务器的终端发送的 curl 请求

0s0u357o

0s0u357o1#

可以使用ip地址,并确保用户是RabbitMQ中的管理员:
https://www.rabbitmq.com/uri-spec.html,带有IP的URI示例:

connection = await aio_pika.connect_robust(
    "amqp://guest:guest@127.0.0.1/",
)

字符串
并检查您是否可以使用例如tcn或其他命令访问远程服务器。
在代码异常后也检查RabbitMQ的日志:

aiormq.exceptions.ProbableAuthenticationError: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.


RabbitMQ Management->Overview->Nodes->Nodename = config and log files location.
经纪人文件(原因如下):

2023-07-23 15:02:48.432000+02:00 [error] <0.55597.0> PLAIN login refused: user 'admin' - invalid credentials


将密码更新为新密码,这可能是问题所在。
示例https://aio-pika.readthedocs.io/en/latest/quick-start.html
工作结果https://github.com/spawnmarvel/test/blob/main/aio5.jpg

相关问题