芹菜:消费者:无法连接到amqp://来宾:** @ 127.0.0.1:5672//:[Errno 92]协议不可用

ott*_*omd 5 python windows ubuntu celery

我一直收到此错误,我也不知道为什么。我在Windows 10上使用Ubuntu,而celery可以正常工作。然后发生了什么,我不断收到此错误。我使用芹菜文档学习。

这是task.py:

from celery import Celery

app = Celery('tasks', broker='pyamqp://guest@localhost//')

@app.task
def add(x, y):
    return x + y
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

[2017-08-14 17:34:04,436: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 92] Protocol not available.
Trying again in 2.00 seconds...

[2017-08-14 17:34:06,453: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 92] Protocol not available.
Trying again in 4.00 seconds...

[2017-08-14 17:34:10,465: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 92] Protocol not available.
Trying again in 6.00 seconds...

[2017-08-14 17:34:16,480: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 92] Protocol not available.
Trying again in 8.00 seconds...
Run Code Online (Sandbox Code Playgroud)

为了启动芹菜我键入:

celery -A tasks worker --loglevel=info
Run Code Online (Sandbox Code Playgroud)

小智 2

您最近更新了 amqp 吗?

自 2.1.2 之后的版本起,由于套接字巫术,似乎不再可能从 Linux 子系统连接到 RabbitMQ 实例。

https://github.com/celery/py-amqp/issues/145

我建议尝试 Celery 可能支持的其他后端,我将尝试 redis。至少降级到 RabbitMQ 2.1.2 也可能解决该问题。