4

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.

2 Answers2

6

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.

Carl Hörberg
  • 5,973
  • 5
  • 41
  • 47
  • 1
    Once you have exceeded your connection limit, is there an easy way to reset your connections to 0? Resetting my dynos does not seem to do the trick. – Jeff Ames May 18 '13 at 20:10
  • @theStreaker123 I use `heroku restart myworker -a myapp` it restarts my workers. – Neara Jul 21 '13 at 11:07
  • 1
    @Jeff This is two years late, but you need to [make sure you have heartbeats setup](https://www.cloudamqp.com/docs/python.html) and then force kill your connections that do not contain heartbeats. You can also set CloudAMQP heartbeats by appending ``?heartbeat=30`` to your CAMQP broker URL but to my knowledge it is undocumented. – grokpot Feb 16 '15 at 19:20
4

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

import djcelery
djcelery.setup_loader()
chris
  • 36,115
  • 52
  • 143
  • 252
Matt Hearn
  • 41
  • 1