Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python RabbitMQ连接关闭异常_Python_Rabbitmq_Pika - Fatal编程技术网

Python RabbitMQ连接关闭异常

Python RabbitMQ连接关闭异常,python,rabbitmq,pika,Python,Rabbitmq,Pika,文件“/usr/local/lib/python2.7/dist packages/pika/adapters/blocking_connection.py”,第218行,进程内数据事件 引发异常。ConnectionClosed() pika.exceptions.ConnectionClosed def main(): print('zmq', zmq.zmq_version(), zmq.pyzmq_version()) zctx = zmq.Context() socket_rep =

文件“/usr/local/lib/python2.7/dist packages/pika/adapters/blocking_connection.py”,第218行,进程内数据事件 引发异常。ConnectionClosed() pika.exceptions.ConnectionClosed

def main():
print('zmq', zmq.zmq_version(), zmq.pyzmq_version())
zctx = zmq.Context()
socket_rep = zctx.socket(zmq.REP)
socket_rep.bind('tcp://*:'+str(dragon_pb2.tcpport.Value('stage1_server_request_storage')))

RabbitReceiver(host='localhost', on_receive_callback=handle_massage, exchange_name='exchange1', queue_name='name1')

while True:
    try:
        request = socket_rep.recv_json()
        status, result = get_records(request)
        if result is None:
            result = {}
        # print result
        socket_rep.send_multipart([status, blosc.compress(json.dumps(result), 9)])

    except KeyboardInterrupt:
        print("Buy")
        sys.exit()


 if __name__ == '__main__':
      main()


class RabbitReceiver(AbstractReceiver):
    def __init__(self, on_receive_callback, host, exchange_name, queue_name):
        AbstractReceiver.__init__(self, host=host, on_receive_callback=on_receive_callback)
        connection = pika.BlockingConnection(pika.ConnectionParameters(
            host=AbstractReceiver.host))
        channel = connection.channel()
        channel.exchange_declare(exchange=exchange_name,
                                 type='fanout')

        channel.queue_declare(queue=queue_name, durable=True)

        channel.queue_bind(exchange=exchange_name,
                           queue=queue_name)
        channel.basic_consume(self.on_message_receive,
                      queue=queue_name)

        channel.start_consuming()

    def on_message_receive(self, channel, method, header, body):
        AbstractReceiver.on_message_receive(self, body)
        channel.basic_ack(delivery_tag = method.delivery_tag)
我知道创建RabbitReceiver之后的代码可能不会执行,因为start\u正在阻塞。但现在我并不担心。 我想知道为什么它会给我这个错误?
在第一条消息到达后,我可能错过了什么…

。您是否检查了rabbitmq日志文件以获取任何线索?