Custom Search

Friday, June 26, 2015

How To Fix Celery ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 104] Connection reset by peer

How To Fix Celery ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 104] Connection reset by peer

1)
$ sudo rabbitmqctl add_user myuser mypassword
Creating user "myuser" ...
...done.

$ sudo rabbitmqctl add_vhost myvhost
Creating vhost "myvhost" ...
...done.

$ sudo rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"
Setting permissions for user "myuser" in vhost "myvhost" ...
...done.

2)
$vim tasks.py

from celery import Celery

app = Celery('tasks', broker='amqp://myuser:mypassword@localhost/myvhost')

@app.task
def add(x, y):
    return x + y

3)
$ celery -A tasks worker --loglevel=info
[2015-06-26 23:49:25,809: WARNING/MainProcess] /home/saju/thrineshwara/myenv/local/lib/python2.7/site-packages/celery/apps/worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.

The pickle serializer is a security concern as it may give attackers
the ability to execute any command.  It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.

If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::

    CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']

You must only enable the serializers that you will actually use.


  warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

 -------------- celery@saju-Inspiron-5521 v3.1.18 (Cipater)
---- **** -----
--- * ***  * -- Linux-3.11.0-26-generic-x86_64-with-Ubuntu-14.04-trusty
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         tasks:0x7f6e3f1e71d0
- ** ---------- .> transport:   amqp://myuser:**@localhost:5672/myvhost
- ** ---------- .> results:     disabled
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
 -------------- .> celery           exchange=celery(direct) key=celery
               

[tasks]
  . tasks.add

[2015-06-26 23:49:25,824: INFO/MainProcess] Connected to amqp://myuser:**@127.0.0.1:5672/myvhost
[2015-06-26 23:49:25,890: INFO/MainProcess] mingle: searching for neighbors
[2015-06-26 23:49:26,914: INFO/MainProcess] mingle: all alone
[2015-06-26 23:49:27,088: WARNING/MainProcess] celery@saju-Inspiron-5521 ready.


3 comments:

  1. http://celery.readthedocs.org/en/latest/getting-started/brokers/rabbitmq.html

    ReplyDelete
  2. http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html

    ReplyDelete