21

我正在尝试让 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 拒绝连接?

4

1 回答 1

59

看起来您需要为“guest”用户授予对“/myapp”虚拟主机的访问权限。

从文档

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

因此,与此类似的内容将为您的来宾用户提供无限制的访问权限:

rabbitmqctl set_permissions -p /myvhost guest ".*" ".*" ".*"
于 2013-06-11T22:06:28.200 回答