MQTT GUIDE
2 min readMQTT Topic Alias
A Topic Alias lets a client or broker replace a long topic name with a small integer for the life of a connection. The first PUBLISH sends the full topic plus an alias number; later PUBLISHes to the same topic send only the number, cutting bandwidth on repetitive, long topic names.
Long, deeply nested topic names are great for organization but wasteful to repeat on every message. MQTT 5.0 adds topic aliases so a client can send a long topic once and then refer to it by a small number.
How topic aliases work
The first time a client publishes to a topic, it includes both the full topic string and an alias — a small integer. The broker records the mapping for that connection. On every later PUBLISH to the same topic, the client leaves the topic string empty and sends only the alias; the broker looks up the alias and treats it as the full topic. How many aliases are allowed is negotiated at connect through the Topic Alias Maximum.
Things to keep in mind
Topic aliases in TBMQ
TBMQ supports topic aliases and advertises a Topic Alias Maximum of 10 by default (configurable, and 0 disables the feature), so a client can map its busiest topics to short integers. See the MQTT protocol guide for supported 5.0 features.
Frequently asked questions
What is a topic alias in MQTT 5.0?
A small integer that stands in for a topic name for the duration of a connection. The first PUBLISH sends the full topic plus the alias to establish the mapping; later PUBLISHes to the same topic send just the alias with an empty topic string, saving bandwidth.
What is the Topic Alias Maximum?
A limit each side advertises for how many distinct aliases the other may use. It is negotiated per direction at connect time: a value of 0 means topic aliases are not allowed in that direction.
Do topic aliases persist across connections?
No. Aliases are scoped to a single connection and reset when the client reconnects. The mapping must be re-established with a full-topic PUBLISH on each new connection.
When are topic aliases worth using?
When a client repeatedly publishes to the same long topic names on a bandwidth-constrained link. Replacing a long hierarchical topic with a one- or two-byte integer on every subsequent message adds up over high message rates.
Are topic aliases available in MQTT 3.1.1?
No. Topic aliases are an MQTT 5.0 feature. In 3.1.1 every PUBLISH must carry the full topic string.
Run it yourself
TBMQ is a free, open-source MQTT broker built to scale. Spin it up in minutes or try the live demo — no install required.