2017-06-23 4 views
3

Utilisation de rabbitmq comme courtier pour le céleri. Problème arrive alors que la commande en cours d'exécutioncéleri: impossible de se connecter à rabbitmq

celery -A proj worker --loglevel=info 
console de céleri

montre ce

[2017-06-23 07:57:09,261: ERROR/MainProcess] consumer: Cannot connect to amqp://bruce:**@127.0.0.1:5672//: timed out. 
Trying again in 2.00 seconds... 

[2017-06-23 07:57:15,285: ERROR/MainProcess] consumer: Cannot connect to amqp://bruce:**@127.0.0.1:5672//: timed out. 
Trying again in 4.00 seconds... 

suivants sont les journaux de rabbitmq

=ERROR REPORT==== 23-Jun-2017::13:28:58 === 
closing AMQP connection <0.18756.0> (127.0.0.1:58424 -> 127.0.0.1:5672): 
{handshake_timeout,frame_header} 

=INFO REPORT==== 23-Jun-2017::13:29:04 === 
accepting AMQP connection <0.18897.0> (127.0.0.1:58425 -> 127.0.0.1:5672) 

=ERROR REPORT==== 23-Jun-2017::13:29:14 === 
closing AMQP connection <0.18897.0> (127.0.0.1:58425 -> 127.0.0.1:5672): 
{handshake_timeout,frame_header} 

=INFO REPORT==== 23-Jun-2017::13:29:22 === 
accepting AMQP connection <0.19054.0> (127.0.0.1:58426 -> 127.0.0.1:5672) 

Toute entrée serait appréciée.

+1

vérifier si le statut 'rabbitmqctl' indique que le noeud est en cours d'exécution ou non –

+0

Vérifiez si votre serveur 'RabbitMq' est en cours d'exécution. Sinon, vous pouvez l'exécuter en utilisant: 'rabbitmq-server'. –

Répondre

0

set CELERY_BROKER_POOL_LIMIT = Aucun dans settings.py

0

Je sais que la fin

Mais je suis tombé sur la même question aujourd'hui, a passé près d'une heure pour trouver la solution exacte. Je pensais que cela pourrait aider quelqu'un d'autre

j'utilise la version de céleri 4.1.0

espère que vous avez configuré correctement RabbitMQ, sinon s'il vous plaît le configurer comme indiqué dans la page http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html#setting-up-rabbitmq

également vérifier si le courtier croix L'URL est correcte. Voici l'url brocker syntaxe AMQP: // user_name: mot de passe @localhost/nom_hôte

Vous pourriez ne pas avoir besoin de spécifier le numéro de port, car il sélectionne automatiquement la valeur par défaut un

Si vous suivez les mêmes variables à partir du lien de tutoriel de configuration ci-dessus votre url Brocker sera comme AMQP: // myuser: mypassword @ localhost/myvhost

Suivre cette structure de projet

Project 
    ../app 
    ../Project 
    ../settings.py 
    ../celery.py 
    ../tasks.py 
    ../celery_config.py 

celery_config.py

# - - - - - - - - - - 
# BROKER SETTINGS 
# - - - - - - - - - - 
# BROKER_URL = os.environ['APP_BROKER_URL'] 
BROKER_HEARTBEAT = 10 
BROKER_HEARTBEAT_CHECKRATE = 2.0 

# Setting BROKER_POOL_LIMIT to None disables pooling 
# Disabling pooling causes open/close connections for every task. 
# However, the rabbitMQ cluster being behind an Elastic Load Balancer, 
# the pooling is not working correctly, 
# and the connection is lost at some point. 
# There seems no other way around it for the time being. 
BROKER_POOL_LIMIT = None 

BROKER_TRANSPORT_OPTIONS = {'confirm_publish': True} 

BROKER_CONNECTION_TIMEOUT = 20 
BROKER_CONNECTION_RETRY = True 
BROKER_CONNECTION_MAX_RETRIES = 100 

celery.py

from __future__ import absolute_import, unicode_literals 
from celery import Celery 

from Project import celery_config 

app = Celery('Project', 
      broker='amqp://myuser:[email protected]/myvhost', 
      backend='amqp://', 
      include=['Project']) 

# Optional configuration, see the application user guide. 
# app.conf.update(
#  result_expires=3600, 
#  CELERY_BROKER_POOL_LIMIT = None, 
#) 

app.config_from_object(celery_config) 

if __name__ == '__main__': 
    app.start() 

tasks.py

from __future__ import absolute_import, unicode_literals 
from .celery import app 


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

Lancez ensuite la céleri avec « céleri -Un travailleur du projet d'info -l » à partir du répertoire du projet

Tout ira bien.