3

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?

Florian Hansen
  • 746
  • 7
  • 19

1 Answers1

3

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.

hardillb
  • 54,545
  • 11
  • 67
  • 105
  • Thank you for your quick answer. I was confident opt. 2 should work, too. Unfortunately, I've just retested it and it does not work. I subscribed the topic "+/data/#". Then I published on "node1/data/update" and received the message (yay). Then I published on "node1/data" and did not receive the message (nay). Seems to be HiveMQ related :( Any other suggestions? – Florian Hansen Jul 31 '19 at 09:29
  • 1
    Then this is a defect in HiveMQ. You should raise a defect – hardillb Jul 31 '19 at 11:05
  • 3
    I have tested it with with the public HiveMQ Broker (broker.hivemq.com) and HiveMQ Community Edition and it works. Which version of HiveMQ are you using? Could you also provide information about the client you are using? – SgtSilvio Aug 01 '19 at 07:39
  • I do not actually know what broker is being used (https://mdash.net/home/). Could this be related to the broker? Maybe it's a custom implementation on their side. My client is a MQTT3 HiveMQ Rx Client. I'll mark this answer as accepted as this should actually work. Thanks anyway (: – Florian Hansen Aug 02 '19 at 07:04
  • This is entirely to do with the broker, not the client. The `hivemq` tag implied that was the broker you were using not the client (and the wording of the question left it ambiguous). As shown by the comments it appears to not be a problem with the HiveMQ Broker. You should inform mdash that their broker is not compliant with the spec. – hardillb Aug 02 '19 at 07:43