How to get detailed log / information of rabbitmq connection activity?

I have a python program connecting to a rabbitmq server. When this program starts up, it connects well. But when the rabbitmq server restarts, my program is unable to reconnect to it and leaving the error only "Socket closed" (the combo created), which is pointless.

I want to know the details of the connection failure. On the server side, there is nothing useful in the rabbitmq log file, it just said "connection failed" with no explanation.

I tried the trace plugin ( https://www.rabbitmq.com/firehose.html ) and found that the tracking information posted to amq.rabbitmq.trace did not fail the connection. I have included the plugin with

rabbitmq-plugins enable rabbitmq_tracing
systemctl restart rabbitmq-server
rabbitmqctl trace_on

      

and then I wrote to the client to receive a message from the amq.rabbitmq.trace exchange:

#!/bin/env python
from kombu.connection import BrokerConnection
from kombu.messaging import Exchange, Queue, Consumer, Producer

def on_message(self, body, message):
    print("RECEIVED MESSAGE: %r" % (body, ))
    message.ack()

def main():
    conn = BrokerConnection('amqp://admin:pass@localhost:5672//')
    channel = conn.channel()
    queue = Queue('debug', channel=channel,durable=False)
    queue.bind_to(exchange='amq.rabbitmq.trace', routing_key='publish.amq.rabbitmq.trace')
    consumer = Consumer(channel, queue)
    consumer.register_callback(on_message)
    consumer.consume()
    while True:
        conn.drain_events()

if __name__ == '__main__':
    main()

      

I also tried to get the debug log from rabbitmq server. I reconfigured rabbitmq.config according to https://www.rabbitmq.com/configure.html and set log_levels to

{log_levels, [{connection, info}]}

      

but as a result the rabbitmq server did not start. Looks like the official doc is not for me, my rabbitmq server version is 3.3.5. However

{log_levels, [connection,debug,info,error]}

      

or

{log_levels, [connection,debug]}

      

works, but there is no DEBUG information showing in the logs with this, and I don't know if it is because the log_levels configuration is ineffective or there is simply no DEBUG log that was printed all the time.

+3


source to share


1 answer


I know this answer comes very late, but for future vendors, this worked for me:

[
  {rabbit,
    [
      {log_levels, [{connection, debug}, {channel, debug}]}
    ]
  }
].

      



Basically, you just need to wrap the options you want to set depending on which module / plugin they belong to.

+3


source







All Articles