Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I subscribe to a MQTT topic which has never been published to?

Tags:

mqtt

mosquitto

My understanding is a topic is not something that really exists until a message is published to.

Is it possible for a client to subscribe to a topic that the broker can see has never been published to? And may not be published to for a while (say a few minutes)?

like image 395
Fachtna Simi Avatar asked Nov 29 '25 08:11

Fachtna Simi


1 Answers

The effect of subscribing to a topic that has never been published to is the same as subscribing to a topic that has been published to (unless there is a message with retain set on that topic).

Your client will wait for messages that are published to that topic. It can wait for a message as long as the client and the broker run and stay connected.

Think of it this way: If a client could not subscribe to a topic that has never been published to, then the first message published on a topic would never reach any clients.

like image 183
Mike Organek Avatar answered Dec 02 '25 01:12

Mike Organek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!