Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection Error with Django/Celery and CloudAMQP/Heroku

I have a Django app that I've already deployed to Heroku. This app uses Celery for message queuing and I've run it locally using RabbitMQ without incident.

Unfortunately, when I went to deploy this baby to Heroku, I found that the RabbitMQ addon wasn't available and that I'd have to use CloudAMQP. The documentation for both CloudAMQP and Heroku lead me to believe that I can use Celery (even though they recommend Pika), but when I try to deploy, I get gnarly connection errors for both my scheduler and worker processes. Here are the exact errors:

2012-07-09T16:46:22+00:00 app[scheduler.1]: [2012-07-09 11:46:22,234: ERROR/Beat] Celerybeat: Connection error: [Errno 111] Connection refused. Trying again in 2.0 seconds...
2012-07-09T16:46:23+00:00 app[worker.1]: [2012-07-09 11:46:23,852: ERROR/MainProcess] Consumer: Connection Error: [Errno 111] Connection refused. Trying again in 2 seconds...

I should note that my Heroku config vars DO have a CLOUDAMQP_URL, so that shouldn't be a problem?

I would appreciate it if anyone who has used CloudAMQP with Django/Heroku could give me some guidance about how to make sure that Celery can connect with the broker.

like image 881
A. Parsons Arroyo Avatar asked Dec 26 '22 21:12

A. Parsons Arroyo


2 Answers

You're probably exceeding the 3 concurrent connections limit of the free plan. Set the BROKER_POOL_LIMIT to 1 and it should work a lot better.

like image 127
Carl Hörberg Avatar answered Jan 05 '23 19:01

Carl Hörberg


Make sure that you have this at the top of your settings.py file.

import djcelery
djcelery.setup_loader()
like image 39
Matt Hearn Avatar answered Jan 05 '23 18:01

Matt Hearn