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... ?

Service Desk Bunny
  • 2,708
  • 1
  • 21
  • 32
HH_Poster
  • 13
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 28 '22 at 06:47

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
  • 68,623
  • 13
  • 106
  • 163
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.