UNSUBSCRIBE
Fixed header flags: 0010 – bit 1 must be 1 (spec §3.10.1)
UNSUBSCRIBE removes one or more topic filter subscriptions from the broker. The broker responds with UNSUBACK. Each topic filter must match the string used in the original SUBSCRIBE exactly – wildcards are not expanded for matching. Fixed header byte is 0xA2 (flags 0010 mandatory).
Details
UNSUBSCRIBE carries a list of topic filters to unsubscribe. The broker will stop delivering messages matching those filters to the client.
The topic filter strings in UNSUBSCRIBE must be byte-for-byte identical to the strings used in SUBSCRIBE. "home/+/temp" and "home/kitchen/temp" are different strings – subscribing to "home/+/temp" and then unsubscribing "home/kitchen/temp" leaves the wildcard subscription active.
MQTT 5.0 adds User Properties to UNSUBSCRIBE for application-level metadata.
Fixed header 0xA2 (1010 0010) – the flags byte 0010 is mandatory per spec §3.10.1, same as SUBSCRIBE and PUBREL.
Fixed Header
| Field | Value |
|---|---|
| Packet type (bits 7–4) | 10 (1010₂) |
| First byte (hex) | 0xA2 |
| Flags (bits 3–0) | 0010 – bit 1 must be 1 (spec §3.10.1) |
| QoS bits apply | No |
| Direction | client-to-server |
| Added in | MQTT 3.1 |