无法连接到RabbitMQ – ACCESS_REFUSED

huangapple go评论63阅读模式
英文:

Can't connect to rabbitmq - ACCESS_REFUSED

问题

大家好!

我想要使用 aio_pika 连接到 RabbitMQ,使用管理员级别的用户名和密码。

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

在连接时发生了错误:

aiormq.exceptions.ProbableAuthenticationError: ACCESS_REFUSED - 使用认证机制PLAIN拒绝登录。有关详细信息,请参阅代理日志文件。

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

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

我登录到界面并获取curl命令的实际值,即网络没有问题,据我了解。

可能的问题是什么?

我正在远程服务器上工作,项目正在Docker中运行,RabbitMQ也在另一台服务器上以Docker方式运行。
我从我工作的远程服务器的终端发送Curl请求。

英文:

everyone!

I want to connect to rabbitmq with aio_pika using an admin level login and password.

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

An error occurs when connecting:

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

I tried connecting through the web interface and the curl command:

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

I login to the interface and get the actual values of the number of curl command, that is, there is no problem with the network, as I understand.

What could be the problem?

I am working on a remote server, the project is running in the docker, Rabbit is running on another server, also in the docker.
Curl request I send from the terminal of the remote server where I work

答案1

得分: 1

也许可以使用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 - 使用身份验证机制PLAIN拒绝了登录。有关详细信息,请参阅代理程序日志文件。

RabbitMQ管理->概述->节点->节点名称=配置和日志文件位置。

代理文件(这是原因):

2023-07-23 15:02:48.432000+02:00 [error] <0.55597.0> PLAIN登录被拒绝:用户'admin' - 无效的凭据

将密码更新为新密码,可能是问题的原因。

示例:
https://aio-pika.readthedocs.io/en/latest/quick-start.html

工作结果:
https://github.com/spawnmarvel/test/blob/main/aio5.jpg

英文:

maybe use the ip-address and make sure the user is an administrator in RabbitMQ:

https://www.rabbitmq.com/uri-spec.html, URI example with IP:

connection = await aio_pika.connect_robust(
    &quot;amqp://guest:guest@127.0.0.1/&quot;,
)

And check that you can reach the remote server with for example tcn or other commands.

Check also in logs for RabbitMQ after code exception:

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.

Broker file (here is the reason):

 2023-07-23 15:02:48.432000+02:00 [error] &lt;0.55597.0&gt; PLAIN login refused: user &#39;admin&#39; - invalid credentials

Update the password to a new password, it could be the issue.

Example
https://aio-pika.readthedocs.io/en/latest/quick-start.html

Working result
https://github.com/spawnmarvel/test/blob/main/aio5.jpg

huangapple
  • 本文由 发表于 2023年5月29日 20:08:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76357240.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定