Contents

MQTT Topic Alias

Overview

The MQTT was designed to support messaging in low bandwidth scenarios; by using Topic Aliases, we can reduce the bandwidth requirements even further.

MQTT Topic Alias

The Topic Alias is a property introduced in the MQTTv5. It reduces the network bandwidth required for the MQTT communication.

A Topic Alias is an integer value that is used to identify the Topic instead of using the Topic Name. This reduces the size of the PUBLISH packet and is useful when the Topic Names are long and/or we work with extremely limited network bandwidth.

MQTT Topic Alias mapping
MQTT Topic Alias mapping

The Sender (Client) decides whether to use a Topic Alias and chooses the integer value. It sets a Topic Alias mapping by including a non-zero length Topic Name and a Topic Alias in the PUBLISH packet.

1
mosquitto_pub -t temp -d -l -D publish topic-alias 1

The Receiver (Broker) processes the PUBLISH as normal, but also sets the specified Topic Alias mapping to this Topic Name.

In further communication, the Topic Name is omitted.

MQTT Topic Alias
MQTT Topic Alias

⚠️Very important: Topic Alias mappings exist only within a Network Connection and last only for the lifetime of that Network Connection.

Mosquitto example

Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker, you can download it from this link.

MQTT Topic Alias example
MQTT Topic Alias example

Mosquitto test
Mosquitto test

Video


Support quality content❤️ Donate💰

Sign up for news: (by subscribing you accept the privacy policy)