允许RabbitMQ-Server连接

时间:2013-06-11 21:56:22

标签: django rabbitmq celery

我正在尝试让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的repo中的标准软件包,默认设置和我的django-celery设置如下:

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "myapp"

为什么RabbitMQ拒绝连接?

1 个答案:

答案 0 :(得分:43)

您似乎需要为“访客”用户授予对“/ myapp”虚拟主机的访问权限。

From the docs

set_permissions [-p vhostpath] {user} {conf} {write} {read}

所以类似的内容会让访客用户无限制地访问:

rabbitmqctl set_permissions -p /myvhost guest ".*" ".*" ".*"