2
votes

I have a MQTT client that wants to subscribe to the following topics

  1. node1/data/updates
  2. node1/data/delta
  3. node1/data

Of course I have multiple nodes, so I have to use wildcards as explained here: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/

I tried the following topic names

  1. +/data/+
  2. +/data/#
  3. +/data# (I was desperat)

Using the above expressions 1 and 2 I did not receive messages for the topic node1/data.

Is there a way to do this with a single subscription?

1

1 Answers

3
votes

Assuming I'm reading the spec right, option 2 should work.

For example, if a Client subscribes to “sport/tennis/player1/#”, it would receive messages published using these topic names:

  • “sport/tennis/player1”
  • “sport/tennis/player1/ranking”
  • “sport/tennis/player1/score/wimbledon”

Option 3 is definitely not valid.

Have you tried testing with mosquitto to see if this is hivemq specific?

EDIT:

I have tested this with mosquito using mosquitto_pub and mosquitto_sub to publish/subscribe messages and with option 2 it works according to the spec.