4

Sending emails with Celery works fine on production server. Trying to use it on local dev (VM) and does not work. I get this when restart:

  • Starting web server apache2 [ OK ]

    • Starting message broker rabbitmq-server [ OK ]
    • Starting celery task worker server celeryd [ OK ]

      Starting celeryev... : No such file or directory

Also I get this error in console when running the page:

error: [Errno 104] Connection reset by peer

Production setting:

import djcelery
djcelery.setup_loader()
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672   # default RabbitMQ listening port
BROKER_USER = "vs_user"
BROKER_PASSWORD = "user01"
BROKER_VHOST = "vs_vhost"
CELERY_BACKEND = "amqp"  # telling Celery to report the results back to RabbitMQ
CELERY_RESULT_DBURI = ""

When i ran:

sudo rabbitmqctl list_vhosts

I get this:

Listing vhosts ...

/

...done.

What i need to change in this setting to run it successfully on local VM?

UPDATE

vhost and user were definitely missing so I ran suggested commands. They executed ok but still it does not work ,same error. It must be one more thing that prevents it from working and celeryev is suspect. This is what i get when stopping and starting server:

  • Stopping web server apache2 ... waiting . [ OK ]
  • Stopping message broker rabbitmq-server [ OK ]
  • Stopping celery task worker server celeryd start-stop-daemon: warning: failed to kill 28006: No such process [ OK ]

Stopping celeryev...NOT RUNNING

  • Starting web server apache2 [ OK ]
    • Starting message broker rabbitmq-server [ OK ]
    • Starting celery task worker server celeryd [ OK ]

Starting celeryev... : No such file or directory

Traceback (most recent call last):

 File "/webapps/target/forums/json_views.py", line 497, in _send_forum_notifications
    post_master_json.delay('ForumNotificationEmail', email_params)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/task.py", line 357, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/task.py", line 474, in apply_async
    **options)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/amqp.py", line 250, in publish_task
    **kwargs
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/messaging.py", line 164, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 470, in _ensured
    interval_max)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 396, in ensure_connection
    interval_start, interval_step, interval_max, callback)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/utils/__init__.py", line 217, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 246, in connect
    return self.connection
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 761, in connection
    self._connection = self._establish_connection()
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 720, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/transport/pyamqp.py", line 115, in establish_connection
    conn = self.Connection(**opts)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/connection.py", line 136, in __init__
    self.transport = create_transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/transport.py", line 264, in create_transport
    return TCPTransport(host, connect_timeout)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/transport.py", line 99, in __init__
    raise socket.error(last_err)
error: timed out

I ran manage.py celeryev and got console showing workers and tasks.Everything is empty and only getting Connection Error: error(timeout('timed out',),) repeatedly.

1 Answer 1

2

It looks like you don't have the virtual host you specified set up on your local RabbitMQ server.

You would first need to add the virtual host.

sudo rabbitmqctl add_vhost vs_vhost

Next you need to add the permissions for your user.

sudo rabbitmqctl set_permissions -p vs_vhost vs_user ".*" ".*" ".*"

Also, make sure that you actually have a user set up, otherwise you can add one using this command.

sudo rabbitmqctl add_user vs_user user01
Sign up to request clarification or add additional context in comments.

3 Comments

It's odd as it says that it is starting RabbitMQ, but the error suggests that it cannot connect to the RabbitMQ server. Are you sure it is running properly? As an example does telnet localhost 5672 work? Also, are you running the python script from localhost as suggested by your config example?
If i run telnet localhost 5672 i get this: Trying ::1... Connected to localhost. Escape character is '^]'. Connection closed by foreign host. Python script is run from 10.0.2.15
So is the Python script running on the same cn as the Python script?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.