RabbitMQ pika.exceptions.ConnectionClosed

Tentei enviar e receber mensagens usando o RabbitMQ. Não tenho formação em ciência da computação, os termos que usei não podem ser muito precisos.

Tento copiar o arquivo do tutorial: Ao enviar meu formulário html, meu script python (cgi) está enviando a mensagem para a fila

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
        channel = connection.channel()
        channel.queue_declare(queue='task_queue', durable=True)
        message = PN
        channel.basic_publish(exchange='',
                              routing_key='task_queue',
                              body=message,
                              properties=pika.BasicProperties(
                                 delivery_mode = 2, # make message persistent
                              ))
        connection.close()

meu receptor está funcionando:

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='task_queue', durable=True)
print(' [*] Waiting for messages. To exit press CTRL+C')

def callback(ch, method, properties, body):
    print(" [x] Received Project %r" % body)
    #ch.basic_ack(delivery_tag = method.delivery_tag) 
    if not (os.path.isfile(js_path)):
        print (' [*] ERROR files missing ')
        #ch.basic_ack(delivery_tag = method.delivery_tag)
        return
    p= subprocess.Popen(run a subprocess here)
    p.wait()

    print (' [*] Temporary Files removed')
    print(" [*] Waiting for messages. To exit press CTRL+C")

channel.basic_qos(prefetch_count=1)
channel.basic_consume(callback,queue='task_queue',no_ack=True)
channel.start_consuming()

Ele gerencia a maior parte do tempo, mas falha aleatoriamente com o seguinte erro:

Traceback (última chamada mais recente): arquivo "Receive5.py", linha 139, no canal.start_consuming () Arquivo "C: \ Python27 \ lib \ pacotes de sites \ pika \ adaptadores \ blocking_connection.py", linha 1681, em start_consuming self.connection.process_data_events (time_limit = None) Arquivo "C: \ Python27 \ lib \ pacotes de sites \ pika \ adapters \ blocking_connection.py", linha 647, em process_data_events self._flush_output (common_terminator) Arquivo "C: \ Python27 \ lib \ pacotes-de-sites \ pika \ adaptadores \ blocking_connection.py ", linha 426, em _flush_output, geram exceções.ConnectionClosed () pika.exceptions.ConnectionClosed