I have a flask app using Celery with RabbitMQ as the broker.
I've followed the instructions in this answer to get started.
I have two machines.
Machine A, where RabbitMQ runs, sends tasks to be consumed by celery on Machine B.
My Broker Url and Backend Result Url are the same: amqp://remote:***@12.345.678.999:5672/remote_host
.
Both machines have copies of the flask app on them. RabbitMQ has been configured so that user remote has all permissions granted ".* .* .*". All the communication between RabbitMQ and Celery works fine when they're both running on localhost on Machine A.
I start celery on Machine B with celery worker -l info -A app.celery
, and everything looks fine:
-------------- celery@ip-XXX-XX-XX-XXX v4.0.0 (latentcall)
---- **** -----
--- * *** * -- Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04- xenial 2016-11-06 18:18:01
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: app:0x7f5b9dd73d90
- ** ---------- .> transport: amqp://remote:**@12.345.578.999:5672/remote_host
- ** ---------- .> results: amqp://
- *** --- * --- .> concurrency: 1 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. app.views.task1
. app.views.task2
. app.views.task3
[2016-11-06 18:18:01,614: INFO/MainProcess] Connected to amqp://remote:**@12.345.678.999:5672/remote_host
[2016-11-06 18:18:01,627: INFO/MainProcess] mingle: searching for neighbors
[2016-11-06 18:18:02,658: INFO/MainProcess] mingle: all alone
[2016-11-06 18:18:02,672: INFO/MainProcess] celery@ip-XXX-XX-XX-XXX ready.
When I run the app on Machine A and try to send a task through RabbitMQ to Celery, I get [Errno 104] Connection reset by peer
with the following (partial) stack trace:
File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/abstract_channel.py", line 67, in wait
self.channel_id, allowed_methods, timeout)
File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/connection.py", line 241, in _wait_method
channel, method_sig, args, content = read_timeout(timeout)
File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/connection.py", line 330, in read_timeout
return self.method_reader.read_method()
File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/method_framing.py", line 189, in read_method
raise m
error: [Errno 104] Connection reset by peer
I also get an AMQP debug statemenet like the following:
amqp: DEBUG: Start from server, version: 0.9, properties: {u'information': u'Licensed under the MPL. See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2015 Pivotal Software, Inc.', u'capabilities':
{u'exchange_exchange_bindings': True, u'connection.blocked': True, u'authentication_failure_close': True, u'basic.nack': True, u'per_consumer_qos': True, u'consumer_priorities': True, u'consumer_cancel_notify': True, u'publisher_confirms': True},
u'cluster_name': u'rabbit@ip-XXX-XX-XX-XXX.ec2.internal', u'platform': u'Erlang/OTP', u'version': u'3.5.7'}, mechanisms: [u'PLAIN', u'AMQPLAIN'], locales: [u'en_US']
I've tried looking at rabbitmqctl list_exchanges, list_consumers, list_bindings, but I haven't been able to make much sense out of them.
How can I debug this to figure out why RabbitMQ can't send tasks to Celery?
I also have same requirements, I also followed this tutorial and It's working fine.
Looks like issue in your broker url, Just try to configure in following way :
And Start worker :
Test it :
and check your terminal you will get expected output.
Note: I don't know it will be work for you or not. I did this and it's working fine for me.