I am trying out how the mqtt v5 features are working with node red.
I am running mqtt against a mosquitto broker.
So one feature I saw, was the use of topicAliases and I imported an example flow provided by @Steve-Mcl .
So what I understood is that if I provide a topic and an topicAlias number, that I can use this number as topicAlias for future messages to public to this topic.
I saw also that in mosquitto 10 topicAlias are available for clients by default.
So what is wrong - and why does this not work?
Sorry for my dumb questions.
Hi, the flow you found was before V5 was finalised and merged.
What happened during development can be read and followed in the PR here: Mqtt5 by Steve-Mcl · Pull Request #2778 · node-red/node-red · GitHub
The salient detail is:
If the user sends topic="foo" topicAlias=2, we check to see if we already know about topicAlias 2 and if it equals "foo". If it is known and matches, we blank out topic so the alias is used. If it isn't known, or doesn't match, we send topic and alias as-is to update the alias on the broker side.
This means a flow that dynamically sets the topic doesn't have to worry about getting the logic right to set topic the first time and not the subsequent times.
I have not exposed topic alias in the node ui. I think my earlier ideas of having the client automatically manage the aliases is worthwhile, but also more work than I can consider right now.
In short, you need to send the topic
AND the topicAlias
, every time. Under the hood, the topic string is removed and thus not transmitted across the network meaning you get the benefit of reduced traffic.
1 Like
Many thanks for your explanation! ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)