gpt4 book ai didi

python-2.7 - celery :连接到 RabbitMQ 服务器时出错

转载 作者:行者123 更新时间:2023-12-03 21:23:55 25 4
gpt4 key购买 nike

我按照这个 "First Steps with Celery" 开始使用 celery .
我完全使用了该链接上指示的 tasks.py。
但是,当我使用运行任务时,

celery -A tasks worker --loglevel=info

我收到此错误:
[2014-09-16 20:52:57,427: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: Socket closed. Trying again in 2.00 seconds...

rabbitmq 服务器肯定正在运行,下面是有关错误的日志片段:
=ERROR REPORT==== 16-Sep-2014::20:53:09 ===
exception on TCP connection <0.235.0> from 127.0.0.1:58162
{channel0_error,starting,
{amqp_error,access_refused,
"AMQPLAIN login refused: user 'guest' - invalid credentials",
'connection.start_ok'}}

=INFO REPORT==== 16-Sep-2014::20:53:09 ===
closing TCP connection <0.235.0> from 127.0.0.1:58162

=INFO REPORT==== 16-Sep-2014::20:53:15 ===
accepted TCP connection on [::]:5672 from 127.0.0.1:58163

=INFO REPORT==== 16-Sep-2014::20:53:15 ===
starting TCP connection <0.239.0> from 127.0.0.1:58163

=ERROR REPORT==== 16-Sep-2014::20:53:18 ===
exception on TCP connection <0.239.0> from 127.0.0.1:58163
{channel0_error,starting,
{amqp_error,access_refused,
"AMQPLAIN login refused: user 'guest' - invalid credentials",
'connection.start_ok'}}

=INFO REPORT==== 16-Sep-2014::20:53:18 ===
closing TCP connection <0.239.0> from 127.0.0.1:58163

有了这个,我做了以下事情来确保'guest'用户对/vhost有权限:
sudo rabbitmqctl set_permissions -p / guest ".*" ".*" ".*"

然后我重新加载/重新启动rabbitmq服务以确保更改生效,
然后再次运行任务。但是,错误仍然相同。

我什至尝试创建一个不同的虚拟主机(jm-vhost)和用户(jm-user1)并再次设置权限以允许所有:
sudo rabbitmqctl add_vhost jm-vhost
sudo rabbitmqctl add_user jm-user1 "" --> "" to make it passwordless (is this correct?)
sudo rabbitmqctl set_permissions -p /jm-vhost jm-user1 ".*" ".*" ".*"

然后将tasks.py修改为:
app = Celery('tasks', broker='amqp://jm-user1@localhost//jm-vhost')

但是当我开始任务时,我仍然得到同样的错误。
我应该如何解决这个问题?提前致谢!

最佳答案

通过执行以下操作,我能够解决这个问题(对于那些有并且将会有同样问题的人)。

我重新创建了我在问题中提到的用户,但这次使用了密码。像这样:

sudo rabbitmqctl add_user jm-user1 sample

然后我再次设置权限:
sudo rabbitmqctl set_permissions -p jm-vhost jm-user1 ".*" ".*" ".*"

重新启动rabbitmq服务器以确保更改生效并对tasks.py进行了修改:
app = Celery('tasks', broker='amqp://jm-user1:sample@localhost/jm-vhost')

我跑的时候,
celery -A tasks worker --loglevel=info

有效 :)。

希望这对其他人有帮助。
多谢你们!

关于python-2.7 - celery :连接到 RabbitMQ 服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25869858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com