Debugging using Wireshark

In the Debugging RabbitMQ's messages recipe, we have seen how to trace messages going to/from RabbitMQ.

However, it is not always possible, or desirable, to stop a running client (or a RabbitMQ server), modify its connection port, and point it to a different one; we just want to monitor the messages that are passing in real-time, impacting the system activity as little as possible.

Tip

However, it's possible to activate the firehose tracer as seen in the recipe, Tracing RabbitMQ's ongoing activity.

Wireshark is a free network analysis tool that has the capability to decode AMQP messages. This tool can be used either on the client side or on the server side to monitor the AMQP traffic flow seamlessly.

Getting ready

To exercise this recipe, you need RabbitMQ up and running and the RabbitMQ Java client library.

How to do it...

In the following steps, we are going to see how to use Wireshark to trace the AMQP messages:

  1. If not already available on your system, download and install Wireshark from http://www.wireshark.org/. You can also install it for your distribution if it is available, for example, with:
    yum install wireshark-gnome
    
  2. Start Wireshark on Linux from the root user.
  3. Start to capture from the loopback interface.
  4. From a terminal from the Java client library path, run the command:
    ./runjava.sh com.rabbitmq.examples.PerfTest -C 1 -D 1
    
  5. Stop the acquisition from the Wireshark GUI and analyze the captured AMQP traffic.

How it works...

Using Wireshark, it is possible to inspect the AMQP traffic exiting or entering a server that is hosting a RabbitMQ server or client.

In our example, we have captured the network traffic running both the client and the server on the same machine, thus connecting in localhost. That's why we were capturing the traffic from the loopback interface (step 3 of the previous steps).

Otherwise, we should capture the traffic from the network interface, usually eth0 or something similar.

Tip

While on Linux, it's possible to capture traffic directed to localhost; the same does not apply to Windows. In this case, the client and the server must be on two different machines, and the capture must be activated on the network interface (either physical or virtual), thus connecting them.

So, in order to run the Wireshark graphical user interface, in case the RabbitMQ client and the server run on the same node, you need to select the loopback interface, as shown in the following screenshot:

How it works...

Tip

On Linux, when you install the Wireshark package, you usually will have the command line interface only, tshark. To have Wireshark with the GUI installed, you have to install the appropriate package. For example, on Fedora, you have to install the wireshark-gnome package.

Once the AMQP traffic has travelled through the loopback interface, it has been captured by Wireshark.

The experiment run in step 4 of the previous steps actually starts both a producer and a consumer with two separated connections.

In order to highlight it, find a packet described as Basic.PublishContent-Header, right-click on it, and select Follow TCP stream. You can then close the window showing the payload dialogue between the client and the server. In the main window, you can now see the network packets that are exchanged between the client and the server, as shown in the following screenshot:

How it works...

In the same way, you can select the traffic exiting the RabbitMQ server, as shown in the following screenshot:

How it works...

In the previous two screenshots, we have highlighted the AMQP payload of both messages, but you will find plenty of details in the AMQP traffic, thanks to the fact that Wireshark includes a very complete AMQP dissector.

There's moreā€¦

In case RabbitMQ is configured to use SSL and you want to analyze the encrypted traffic, this is possible under some given conditions by properly configuring the SSL public/private keys in the Wireshark configuration.

Find more information at http://wiki.wireshark.org/SSL.

See also

You can find some references to the Wireshark AMQP dissector at http://wiki.wireshark.org/AMQP.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset