The quick download:
Packet captures reveal what your monitoring dashboard can’t: the exact moment and reason an MQTT session slows down.
-
MQTT control packets (CONNECT, SUBSCRIBE, PUBLISH, DISCONNECT) follow a predictable sequence you can trace in Wireshark to isolate handshake delays, broker rejections, and QoS acknowledgment gaps.
-
Synthetic monitoring metrics such as connect, subscribe, and publish time can be correlated with packet-level events, helping you investigate which stage of an MQTT exchange is contributing to a slowdown.
-
TLS on port 8883 hides MQTT fields unless you supply session secrets; plaintext captures on port 1883 show every flag and payload immediately.
-
Set up continuous synthetic MQTT monitoring so you have baseline metrics ready the next time a capture is worth taking.
Editor’s note: This post was originally published on July 6, 2017, and has been updated since Catchpoint became LogicMonitor Digital Experience.
MQTT is a lightweight publish/subscribe protocol that moves telemetry between devices, gateways, and applications with minimal overhead. To analyze and troubleshoot MQTT traffic with Wireshark, you capture a live session and read each control packet in order, from CONNECT through DISCONNECT. This article walks through an MQTT 3.1.1 capture packet by packet so you can tell a healthy session from a failing one.
MQTT’s low overhead is why it runs across IoT fleets, industrial telemetry, and mobile backends. When the message flow slows, published readings can arrive several seconds late while the broker’s status page still shows green. That late-delivery gap is easy to miss, which is why packet-level analysis earns its place next to your other monitoring.
This guide is written for network engineers, site reliability engineers, and IoT practitioners. It helps you move past “the broker is up” and see what the connection is actually doing.
Continuous synthetic and platform monitoring tells you when and where MQTT behavior degrades. A packet capture inspects one representative session in detail. Monitoring flags the problem, and the capture explains it.
The test used Synthetic monitoring to subscribe and publish to a topic on an MQTT broker. The image below illustrates the test setup for MQTT monitoring.

Metrics from the MQTT test included publish time, publish size, subscribe time, subscribe size, DNS, and connect time. To interpret the data collected by the monitor, the test team captured a live MQTT session with Wireshark and read it packet by packet. Sniffing tools such as Wireshark dissect each step in the exchange and expose the data packets, making it easier to see what happens under the hood.

What MQTT version does this capture use?
This capture uses MQTT 3.1.1. That version still runs on many deployed devices and brokers, so it’s a practical baseline for reading a trace. If you work with MQTT 5, the sequence looks familiar, but several fields have changed.
- Clean Session became Clean Start, paired with a separate Session Expiry Interval that sets how long the broker keeps session state.
- CONNACK carries a reason code and properties instead of the older single return-code model.
- Reason codes and properties were added to more control packets for more specific feedback.
- The core flow is the same: CONNECT, CONNACK, SUBSCRIBE, SUBACK, and PUBLISH follow the sequence below.
For the full list of changes, see the MQTT 5 specification from OASIS.
How do you set up Wireshark to capture MQTT?
MQTT runs over TCP/IP, so you capture it like any TCP stream and then apply an MQTT display filter. Before you capture, confirm four things about the session you plan to inspect.
- Capture location: capture where the traffic flows, on the client host, the broker host, or a segment that sees both sides.
- MQTT version: confirm whether the client and broker use 3.1.1 or 5, since the fields differ.
- Encryption status: confirm whether the connection uses plaintext TCP or TLS, which changes what Wireshark can show.
- Display filter: apply the mqtt display filter to isolate MQTT traffic. Wireshark’s MQTT dissector reference lists the fields at wireshark.org/docs/dfref/m/mqtt.html.
This example uses QoS 0, the simplest delivery level, so the trace stays focused on the core exchange. The Wireshark snapshot below shows a subscribe followed by a publish to the same broker, in the order the packets arrived.

In the image above, 192.168.0.11 is the MQTT broker and 192.168.0.12 is the client, which acts as both the publisher and the subscriber.
What ports does MQTT use?
MQTT uses port 1883 for plain TCP and port 8883 for MQTT over TLS. The capture above uses 1883, the registered port for unencrypted MQTT. Port 8883 doesn’t by itself secure a connection, because TLS still has to be configured and validated on both ends.
Can Wireshark read MQTT over TLS?
Wireshark can read MQTT fields inside TLS only if you give it the session secrets, usually through a TLS key log file. Without those secrets, you see the TLS handshake and encrypted records but not the CONNECT or PUBLISH fields.
1. What is the MQTT CONNECT packet?
The CONNECT packet is the first message a client sends to open a session with the broker. In standard MQTT operation, the connection runs between a client and a broker, not directly between two clients. Once the broker accepts it, the connection stays open until it closes.
A clean DISCONNECT from the client is one way the connection ends. It can also end through transport failure, a keep-alive timeout, broker shutdown, administrative action, or other errors.

The CONNECT packet carries these fields:
- Header Flags: identify the MQTT control packet type.
- Connect Flags: a byte of flags that set connection behavior and signal which optional fields appear in the payload.
- Clean Session: Bit 1. When true, subscriptions drop on disconnect; when false, they persist and queued high-QoS messages arrive on reconnection.
- Will flag: Bit 2, part of the last will and testament (LWT). When set, the broker stores a Will message (Will Topic plus Will Message).
- Will QoS: Bits 4 and 3. Set the QoS level the broker uses when it publishes the Will message.
- Will Retain: Bit 5. If 0, the broker publishes the Will as non-retained; if 1, it publishes it as retained.
- User Name and Password: Bits 7 and 6. When set, the broker expects those credentials in the payload for authentication and authorization.
- Keep Alive: the interval the broker uses to decide whether the client is still on the network.
- Client ID: an identifier for the client that must be unique per broker.
- Payload: carries the Client ID, Will Topic, Will Message, User Name, and Password, depending on the flags.
The broker publishes the Will message on the client’s behalf when the connection drops ungracefully, so it works mainly as a failure-detection signal. A clean DISCONNECT normally suppresses the Will, so other clients aren’t notified on an orderly shutdown. When there’s no TLS underneath, the password travels in plaintext.
If a CONNECT gets no CONNACK, check TCP, TLS, authentication, the listener, and broker availability. Confirm the transport actually connected before you suspect MQTT itself.
2. What is the CONNACK packet?
The CONNACK packet is the broker’s reply to a CONNECT, and it reports whether the connection was accepted. The broker sends one CONNACK for each CONNECT it receives.

CONNACK carries these fields:
- Header Flags: identify the MQTT control packet type.
- Session Present: Bit 0 of the acknowledge byte. It shows whether the broker already holds a persistent session for this client.
- Return Code: in MQTT 3.1.1, reports success or the reason for refusal. MQTT 5 replaces it with a reason code and properties.
The return code values and their meanings appear below.

- Payload: the CONNACK has no payload.
If the CONNACK reports failure, read the returned return or reason code. Correlate it with credentials, authorization rules, connection quotas, or a protocol-version mismatch between client and broker.
3. What is the SUBSCRIBE packet?
The SUBSCRIBE packet is how a client asks the broker to send it messages on one or more topics. Each SUBSCRIBE lists topic filters and the QoS the client wants for each.

- Header Flags: identify the MQTT control packet type.
- Packet Identifier: required in every SUBSCRIBE, regardless of the topic QoS. The broker echoes it in the SUBACK to match response to request.
- Topic and QoS level: each subscription pairs a topic filter with a QoS level. The topic is the subject the client wants messages on.
- Payload: a list of subscriptions. A SUBSCRIBE payload is mandatory.
The packet identifier is separate from the subscription QoS. The identifier correlates the request and its response, while the QoS governs how the broker later delivers messages on that topic.
If a SUBSCRIBE gets no matching SUBACK, suspect broker delay, a topic authorization failure, packet loss, or an interrupted connection. Check whether the connection was still open when the SUBSCRIBE went out.
4. What is the SUBACK packet?
The SUBACK packet is the broker’s confirmation of a SUBSCRIBE. It returns one code per requested topic to show whether each subscription succeeded.

- Header Flags: identify the MQTT control packet type.
- Packet Identifier: the same identifier the client sent in the SUBSCRIBE, used to match this SUBACK to the request.
- Return Code: one code per topic/QoS pair. On success, the code reflects the granted QoS level.
The return code values and their meanings appear below.

- Payload: a list of return codes.
5. What is the PUBLISH packet?
The PUBLISH packet carries an application message from a connected client to the broker, which then forwards it to matching subscribers. A client can publish once it’s connected.

- Header Flags: identify the MQTT control packet type.
- DUP flag: 0 marks a first send; 1 marks a possible re-send of this PUBLISH.
- QoS: sets the delivery assurance level for the message.
- Retain flag: if 1, the broker stores the message and its QoS to serve future subscribers on the topic.
- Topic Name: a UTF-8 string, optionally hierarchical with forward slashes, that the broker uses for subject-based filtering.
- Message: the payload data being sent. MQTT is data-agnostic, so the structure depends on the use case.
- Payload: the message being published.
The retain flag also drives a delivery rule. The broker sets it to 1 when a message is sent because of a new subscription. It sets the flag to 0 when the message matches an existing subscription, regardless of how that message was originally received.
This example publishes at QoS 0, so you see a single PUBLISH and no PUBACK. The broker delivers the message at most once and keeps no acknowledgment record. Higher QoS levels change what the trace looks like.
| QoS level | What the trace shows | Delivery guarantee |
|---|---|---|
| QoS 0 | One PUBLISH, no acknowledgment | At most once |
| QoS 1 | PUBLISH paired with a PUBACK | At least once |
| QoS 2 | PUBLISH, PUBREC, PUBREL, PUBCOMP | Exactly once |
At QoS 1, a missing PUBACK signals a delivery problem. QoS 2 adds round trips to guarantee exactly-once delivery.
If a publish succeeds but never reaches a subscriber, check for a topic mismatch, QoS behavior, retained-message expectations, or subscription state on the broker. Confirm both sides use the same topic string first.
6. What is the DISCONNECT packet?
The DISCONNECT packet is a control message the client sends to close the session cleanly. It’s one of several ways a connection ends, alongside keep-alive timeouts and transport failures.

- Header Flags: identify the MQTT control packet type.
- Payload: the DISCONNECT has no payload.
A clean DISCONNECT tells the broker the client is leaving on purpose, so the broker suppresses the client’s Will message.
7. How does MQTT keep-alive work?
MQTT keep-alive confirms the connection is open and that both the client and the broker are still reachable. At connect time, the client tells the broker a keep-alive interval in seconds.
The rule, in plain terms: the client keeps the gap between the control packets it sends within the keep-alive value. Any MQTT control packet counts as activity, so a busy client may never need to ping. When it has nothing else to send, the client sends a PINGREQ to hold the connection open.
The broker watches for activity too. If it sees no packet within roughly 1.5 times the keep-alive interval, it can treat the client as gone and close the connection.
PINGREQ and PINGRESP messages carry the keep-alive exchange. A typical flow looks like the image below.

PINGREQ
The client sends a PINGREQ when it has sent no other control packet and wants to show it’s still alive. If the broker receives nothing within the keep-alive window, it closes the connection. On an ungraceful loss, it also publishes the client’s LWT message if one was set.

- Header Flags: identify the MQTT control packet type.
- Payload: the PINGREQ has no payload.
PINGRESP
The PINGRESP is the broker’s reply to a PINGREQ, and it confirms the broker is still available to the client.

- Header Flags: identify the MQTT control packet type.
- Payload: the PINGRESP has no payload.
Irregular PINGREQ and PINGRESP timing points to an idle connection, network loss, an overloaded broker, or too aggressive a keep-alive interval. Compare the observed ping gaps against the negotiated interval.
How do Synthetics signals map to packet evidence?
Synthetic monitoring measures the “what”: publish time, subscribe time, connect time, DNS, and availability, tracked continuously and by location. These measurements support Internet Performance Monitoring by helping teams investigate how Internet paths and third-party dependencies affect MQTT delivery. A packet capture supplies the “why” behind a degraded signal. The table below shows packet evidence to inspect when common monitor signals degrade.
| Monitor signal | Packet evidence to inspect |
|---|---|
| Elevated connect time | Inspect the TCP handshake first, then check TLS and MQTT CONNECT-to-CONNACK timing separately to determine whether additional delay occurs after the TCP connection is established. |
| Elevated subscribe time | Inspect the SUBSCRIBE/SUBACK exchange and the subsequent PUBLISH delivery to the subscriber, including any network delay, broker processing, or QoS acknowledgments involved. |
| Elevated publish time | PUBLISH flow, QoS acknowledgments, and any retransmissions |
| Intermittent availability | Keep-alive gaps, connection resets, reconnects, and LWT behavior |
| Regional degradation | Compare synthetic results by location first, then capture locally where the problem appears |
Broker health also shows up in signals beyond a single session, such as connection counts, message rates, subscription counts, queue depth, and delivery latency.
Turn MQTT captures into faster fixes
Reading an MQTT capture turns a vague slowdown into a specific cause. The workflow has three steps: detect, diagnose, and correlate.
Detect a change with continuous synthetic monitoring. Diagnose it by inspecting the packets for the affected phase of the exchange. Correlate the timing against the connect, subscribe, and publish metrics you already track.
That sequence narrows where an issue starts, whether it’s in the transport, the broker, authorization, or topic configuration.
For your next step, set up continuous MQTT monitoring with LM Internet Performance Monitoring. You’ll have the baseline metrics ready the next time a capture is worth taking.
See how MQTT timing metrics connect to real packet evidence.
LogicMonitor Digital Experience tracks connect, subscribe, and publish latency across locations. When something slows down, you’ll have the baseline to know where to look.
FAQs
What ports does MQTT use, and how do they affect what Wireshark can capture?
MQTT uses port 1883 for plain TCP and port 8883 for TLS-encrypted connections. On port 1883, Wireshark displays all MQTT control packet fields in clear text. On port 8883, you’ll see only the TLS handshake and encrypted records unless you provide session secrets through a TLS key log file.
How do MQTT QoS levels change what appears in a Wireshark trace?
QoS 0 produces a single PUBLISH with no acknowledgment (at-most-once delivery). QoS 1 adds a PUBACK after each PUBLISH (at-least-once). QoS 2 shows a four-packet handshake: PUBLISH, PUBREC, PUBREL, PUBCOMP (exactly-once). The QoS level determines how many packets you’ll see per message and which acknowledgment gaps to look for during troubleshooting.
How does MQTT keep-alive work, and what should I look for if connections drop unexpectedly?
The client sets a keep-alive interval at connect time and must send a control packet (or a PINGREQ) within that window to hold the connection open. The broker closes the connection if it sees no activity within roughly 1.5 times the interval. Irregular PINGREQ/PINGRESP timing in your capture can indicate an idle connection, network loss, an overloaded broker, or a keep-alive value set too aggressively.




