2012-05-16 9 views
11

Sto provando a mettere su sedano con django e coniglio-mq. Finora, ho fatto quanto segue:Errore di connessione del consumatore con django e sedano + rabbitmq?

  • sedano installata da pip
  • RabbitMQ installato tramite il Debs disponibile dal loro repository
  • Aggiunto un utente e vhost per RabbitMQ via rabbitmqctl, così come i permessi per quell'utente
  • introduttiva il RabbitMQ server
  • installata django-sedano tramite pip
  • Impostare django-sedano, compresi i suoi tavoli
  • Configurate le varie cose in settings.py (BROKER_HOST, BROKER_PORT, BROKER_USER, BROKER_PASSWORD, BROKER_VHOST, così come importando djecelery, richiamando la funzione di installazione e aggiungendola all'APPS INSTALLATO). Ho ricontrollato e tutti questi valori sono corretti (almeno, user, password e vhost sono corretti).

Così ora, quando corro python manage.py celeryd -l info ottengo errori di connessione (vedi sotto). Qualcuno ha qualche idea del perché?

$ python manage.py celeryd -l info 
/usr/local/lib/python2.7/dist-packages/djcelery/loaders.py:108: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments! 
    warnings.warn("Using settings.DEBUG leads to a memory leak, never " 
[2012-05-15 18:38:04,486: WARNING/MainProcess] 

-------------- [email protected] v2.5.3 
---- **** ----- 
--- * *** * -- [Configuration] 
-- * - **** --- . broker:  amqp://[email protected]:5672/celeryhost 
- ** ---------- . loader:  djcelery.loaders.DjangoLoader 
- ** ---------- . logfile:  [stderr]@INFO 
- ** ---------- . concurrency: 1 
- ** ---------- . events:  OFF 
- *** --- * --- . beat:  OFF 
-- ******* ---- 
--- ***** ----- [Queues] 
-------------- . celery:  exchange:celery (direct) binding:celery 


[Tasks] 


[2012-05-15 18:38:04,562: INFO/PoolWorker-1] child process calling self.run() 
[2012-05-15 18:38:04,565: WARNING/MainProcess] [email protected] has started. 
[2012-05-15 18:38:07,572: ERROR/MainProcess] Consumer: Connection Error: [Errno 104] Connection reset by peer. Trying again in 2 seconds... 
^C[2012-05-15 18:38:08,434: WARNING/MainProcess] celeryd: Hitting Ctrl+C again will terminate all running tasks! 
[2012-05-15 18:38:08,435: WARNING/MainProcess] celeryd: Warm shutdown (MainProcess) 
[2012-05-15 18:38:09,372: INFO/PoolWorker-1] process shutting down 
[2012-05-15 18:38:09,373: INFO/PoolWorker-1] process exiting with exitcode 0 
[2012-05-15 18:38:09,376: INFO/MainProcess] process shutting down 
+0

ho incontrato lo stesso problema –

risposta

1

Il server rabbitmq non deve essere attivo e/o configurato correttamente. Verificare che sia e riprovare - o, meglio ancora, se si sta solo provando a testare qualcosa e si è in coda agnostica, estrarre rabbitmq e iniziare a utilizzare i redis. È molto più facile da configurare.

ho appena tagliato e incollato questo codice da uno del mio progetto, e funziona bene:

import djcelery 
from datetime import timedelta 

djcelery.setup_loader() 


BROKER_BACKEND = "redis" 
BROKER_HOST = "localhost" 
BROKER_PORT = 6379 
BROKER_VHOST = "0" 

CELERYD_LOG_LEVEL = 'DEBUG' 
CELERY_RESULT_BACKEND = "redis" 
CELERY_TASK_RESULT_EXPIRES = 150000 
REDIS_HOST = "localhost" 
REDIS_PORT = 6379 
REDIS_DB = "0" 
CELERYD_CONCURRENCY = 1 
CELERYD_MAX_TASKS_PER_CHILD = 4 

CELERY_IMPORTS = (
    "apps.app1.tasks", 
    "apps.app2.tasks", 
) 
1

cosa fa il tuo BROKER_URL assomigliare a settings.py?

Per RabbitMQ default ha un Visitatore, quindi se è possibile connettersi con

BROKER_URL = "amqp://guest:[email protected]:5672//" 

allora il problema è il vostro setup per RabbitMQs utente, password o virtualhost.

12

Il tuo problema è nel BROKER_URL.

Con un ulteriore VHOST, la configurazione giusta sarebbe:

BROKER_URL='amqp://[email protected]:5672//' 
BROKER_VHOST='/celeryhost' 
+5

l'impostazione 'BROKER_VHOST' è deprecato. Puoi impostare 'VHOST' nella variabile' BROKER_URL': 'BROKER_URL = 'amqp: // celeryuser @ localhost: 5672/celeryhost'' –

+1

per me l'URL del broker ha funzionato solo con una doppia barra prima del vhost: BROKER_URL =' AMQP: // celeryuser @ localhost: 5672 // celeryhost' –

4

Per me, il seguente URL che termina lavorato: ... @ localhost: 5672/celeryvhost

4

ho avuto problema simile con RabbitMQ e il problema era che il mio utente non ha il permesso di creare messaggi in RabbitMQ.

Prova eseguire il seguente script sul server RabbitMQ con ospite utente e se si crea un processo di provare con l'utente:

from celery import Celery 

app = Celery('tasks', broker='amqp://radek:**@localhost:5672//') 

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

Se hai lo stesso errore appena istituito il permesso per la vostra utente:

rabbitmqctl set_permissions -p/radek ".*" ".*" ".*"