允许 RabbitMQ-Server 连接
Posted
技术标签:
【中文标题】允许 RabbitMQ-Server 连接【英文标题】:Allowing RabbitMQ-Server Connections 【发布时间】:2013-06-07 22:02:06 【问题描述】:我正在尝试让 Django Celery 工作人员连接到 RabbitMQ 服务器,所有服务器都在同一主机上运行。
但是,当我运行 manage.py celery worker
时,我得到的只是:
[2013-06-11 17:33:41,185: WARNING/MainProcess] celery@localhost has started.
[2013-06-11 17:33:44,192: ERROR/MainProcess] Consumer: Connection Error: Socket closed. Trying again in 2 seconds...
[2013-06-11 17:33:50,203: ERROR/MainProcess] Consumer: Connection Error: Socket closed. Trying again in 4 seconds...
[2013-06-11 17:34:03,214: ERROR/MainProcess] Consumer: Connection Error: Socket closed. Trying again in 6 seconds...
[2013-06-11 17:34:27,232: ERROR/MainProcess] Consumer: Connection Error: Socket closed. Trying again in 8 seconds...
当我检查我的/var/log/rabbitmq/rabbit@localhost.log
时,我看到了几条消息,例如:
=ERROR REPORT==== 11-Jun-2013::17:33:44 ===
exception on TCP connection <0.201.0> from 127.0.0.1:43461
channel0_error,opening,
amqp_error,access_refused,
"access to vhost 'myapp' refused for user 'guest'",
'connection.open'
我正在使用 Ubuntu 12.04 存储库中的标准包,默认设置和我的 django-celery 设置如下所示:
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "myapp"
为什么 RabbitMQ 拒绝连接?
【问题讨论】:
【参考方案1】:您似乎需要为“guest”用户授予对“/myapp”虚拟主机的访问权限。
From the docs:
set_permissions [-p vhostpath] user conf write read
因此,与此类似的内容将为您的访客用户提供无限制的访问权限:
rabbitmqctl set_permissions -p /myvhost guest ".*" ".*" ".*"
【讨论】:
如果我想在从 rabbitmq 图像创建时默认授予对我的虚拟主机的完全访问权限,该怎么办?因为如果我们在 docker 容器中运行应用程序,那么在这种情况下,我们通常不需要任何手动权限来使应用程序正常工作。以上是关于允许 RabbitMQ-Server 连接的主要内容,如果未能解决你的问题,请参考以下文章