1

I try to publish a message like so:

mosquitto_pub  -h 7.18.13.43 -t "Home/#" -m "test bulb1"  -v  -u user1
-P md

CError: Invalid publish topic 'Home/#', does it contain '+' or '#'?

mosquitto_pub -h 7.18.13.43 -t # -m "test bulb1" -u user1 -P md

Error: Invalid publish topic '#', does it contain '+' or '#'?

I don't understand why I get these errors... ?

HH_Poster
  • 13
  • 2

2 Answers2

1

Im no expert, but surely you should replace "#" with an actual topic name.

If I understand correctly, # is a wilcard, which makes sense when subscribing but not publishing.

This is also consistent with the error you are getting.

davidgo
  • 73,366
0

From my experience, I know that # is an MQTT wildcard, meaning that all topics (topic hierarchy levels) that go after it should be included as well. Actually, wildcards are supported for subscribing to topics, not publishing. When I had the same issue, I was very lucky to come up with this solution. So, I really hope it will be helpful for you. Anyway, if you’re still going through the same problem, check MQTT publish subscribe for more information. I’ll be waiting for your reply, mate.