WebFaction
Community site: login faq

Greetings. I have a fully functional Django project deployed on Webfaction that i want to add Celery + RabbitMQ to. Following the Celery 3.1.13 docs (http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html), I added Celery + RabbitMQ to the project in my (non-Webfaction) development environment, and everything works fine. Now i'm trying to deploy the new set up to Webfaction and am encountering difficulties. Here's where i'm at. By the way, i would love it if Webfaction could write an up-to-date guide on this process, because the community questions and answers i've found don't describe it in full detail.

1) Following the latest guide on the topic that i could find (https://www.zoe.vc/2013/celery-with-rabbitmq-3-1-0-on-webfaction/), i installed Erlang and RabbitMQ.

2) I started Erlang on port 23781, the port specified by the custom Erlang app i created via the Webfaction Control Panel:

$ epmd -port 23781 -daemon

3) I started RabbitMQ on port 15711, the port specified by the custom RabbitMQ app i created via the Webfaction Control Panel:

$ rabbitmq_server-3.3.4/sbin/rabbitmq-server -detached
$ rabbitmq_server-3.3.4/sbin/rabbitmqctl status
Status of node rabbit@dweb125 ...
[{pid,30453},
 {running_applications,[{rabbit,"RabbitMQ","3.3.4"},
                        {os_mon,"CPO  CXC 138 46","2.2.15"},
                        {mnesia,"MNESIA  CXC 138 12","4.12.1"},
                        {xmerl,"XML parser","1.3.7"},
                        {sasl,"SASL  CXC 138 11","2.4"},
                        {stdlib,"ERTS  CXC 138 10","2.1"},
                        {kernel,"ERTS  CXC 138 10","3.0.1"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:8:8] [async-threads:30] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,38570504},
          {connection_procs,2808},
          {queue_procs,5616},
          {plugins,0},
          {other_proc,13966072},
          {mnesia,60656},
          {mgmt_db,0},
          {msg_index,24344},
          {other_ets,804192},
          {binary,15336},
          {code,16595244},
          {atom,654217},
          {other_system,6442019}]},
 {alarms,[]},
 {listeners,[{clustering,35711,"::"},{amqp,15711,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,6682899251},
 {disk_free_limit,50000000},
 {disk_free,1783272325120},
 {file_descriptors,[{total_limit,19900},
                    {total_used,3},
                    {sockets_limit,17908},
                    {sockets_used,1}]},
 {processes,[{limit,1048576},{used,129}]},
 {run_queue,0},
 {uptime,16}]
...done.

4) I checked the status of the Erlang process:

$ epmd -port 23781 -names
epmd: up and running on port 23781 with data:
name rabbit at port 35711

I don't why the rabbit port listed is 35711 and not 15711.

5) Disregarding the port discrepancy, i changed directory to my Django project <proj>, activated my virtual environment (which has Celery installed in it), and ran

 $ celery -A <proj> worker -l info
...
[2014-08-01 12:03:25,938: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.
Trying again in 2.00 seconds...

Bang! :-( What's going wrong here?

Thanks for your attention.

asked 01 Aug '14, 00:19

araichev
25139
accept rate: 50%

edited 01 Aug '14, 00:25

Your error message mentions that it's trying to connect to 127.0.0.1:5672, which isn't either of those ports. Can you tell us how you configured this port?

(01 Aug '14, 05:06) ryans ♦♦

I don't know where that port 5672 is coming from. Here's my celery.py file in my project. I've replaced the real project name with proj.

I'll open a supoort ticket on this issue too.

from __future__ import absolute_import
import os

from celery import Celery
from django.conf import settings

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')

app = Celery('proj')

# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))
(01 Aug '14, 21:31) araichev

Bjoern M of Webfaction answered my support ticket and pointed me toward a fix. As @ryans noted above, Celery was looking for the RabbitMQ server on the wrong port, port 5672, which is the default Celery config port. I needed to set

BROKER_URL = 'amqp://guest:guest@localhost:15711//'

in my Django production settings file to instruct Celery to look on the right port, port 15711.

Celery works now. Thanks!

permanent link

answered 01 Aug '14, 23:31

araichev
25139
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×906
×21
×12

question asked: 01 Aug '14, 00:19

question was seen: 20,146 times

last updated: 01 Aug '14, 23:31

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM