# MQTT every ten seconds question - multiple clients

**URL:** <https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203>\
**Category:** General\
**Created:** [21 February 2019 04:13 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203 "2019-02-21T04:13:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2019 04:13 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/1 "2019-02-21T04:13:25Z")

</div>

I have a flow in Node Red that publishes data over MQTT every ten seconds. It works fine in my testing with one client, a NodeMCU that subscribes to the topics and displays the message data. But, what happens if I have multiple clients subscribing to the same topics? Do I understand correctly that the MQTT broker keeps track of which clients haven't gotten their data, even with a QOS of zero? It's OK if the clients sometimes miss getting the data, but I am wondering the best practice here- separate topics for each client? Higher QOS?

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [21 February 2019 08:33 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/2 "2019-02-21T08:33:07Z")

</div>

This 10? part guide linked below is worth reading to answer most questions on how MQTT works...

[https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt/](https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt/)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 February 2019 09:14 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/3 "2019-02-21T09:14:55Z")

</div>

Whether you have one or 100 clients subscribing to a topic should make no difference to the way each client is handled.  
When you ask whether it keeps track of which clients have not got the data, what sorts of reason that might prevent them getting the data are you thinking of?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 February 2019 09:34 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/4 "2019-02-21T09:34:52Z")

</div>

The QoS is exactly that - a Quality fo Service... So for QoS 0 (fire and forget) the broker will send the message to each subscribed client - but doesn't check for an acknowledgment back. Qos 1 (at least once) - it retries until it gets an ack back (so may send more than once), QoS2 (once and once only) - it checks that it only gets received once. So depending on the QoS it does more or less "tracking". Clients can subscribe with whatever QoS they want.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2019 14:08 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/5 "2019-02-21T14:08:18Z")

</div>

> [@Colin](#):
>
> what sorts of reason that might prevent them getting the data are you thinking of?

Thanks. With the two clients side-by-side, sometimes only one would update. Maybe one out of 20 messages. But, as I said, it is no problem if missed data is that infrequent. I just wondered if QOS "fire and forget" was the right level.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2019 14:11 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/6 "2019-02-21T14:11:20Z")

</div>

> [@dceejay](#):
>
> Clients can subscribe with whatever QoS they want.

This is the part of QOS that confuses me- if I publish with a QOS of 0, what difference does it make what QOS level that is set by the subscriber?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 February 2019 15:25 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/7 "2019-02-21T15:25:53Z")

</div>

AFAIK the two QOSes are basically separate (but do have affects on overall system behaviours)  
Publish at QOS0 just mean the broker MIGHT get the message

Publish at QOS1 means the broker will def get the message but might get it several times

Publish as QOS2 means the broker will only get the message once

Once the broker has the message - it forwards it based on subscribing clients QOS topic setting

So if published at QOS0 - its possible that no QOS2 client will get the message as its not guaranteed to have reached the broker in the 1st place

Any QOS1 or 2 published message is guaranteed to get to a QOS1 or QOS2 subscribing client

Simon

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2019 16:06 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/8 "2019-02-21T16:06:25Z")

</div>

OK, I think I grok. I need to think of the publisher to client in two discrete steps and not a single path.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 February 2019 16:14 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/9 "2019-02-21T16:14:52Z")

</div>

> [@SteveMann](#):
>
> sometimes only one would update. Maybe one out of 20 messages

Is your mqtt server local or is it on the internet? With everything on the local internet then that should not happen, even with QOS 0.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 February 2019 16:15 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/10 "2019-02-21T16:15:55Z")

</div>

> [@SteveMann](#):
>
> I need to think of the publisher to client in two discrete steps

Yes, there is no publisher to client path. It is publisher to broker and broker to client(s).

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2019 16:44 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/11 "2019-02-21T16:44:51Z")

</div>

> [@Colin](#):
>
> Is your mqtt server local

It's local. And I haven't seen the anomaly again, so it could easily have been something else in my code.  
Thanks for the info.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [22 February 2019 08:52 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/12 "2019-02-22T08:52:47Z")

</div>

> [@cymplecy](#):
>
> Once the broker has the message - it forwards it based on subscribing clients QOS topic setting

Not quite. The Broker should never upgrade the qos of a message - it will only ever downgrade it to match the subscription qos.

- A message that was published at qos 0 will be sent as qos 0 to all subscribers regardless of their qos (as qos 0 will not get upgraded to 1 or 2).
- A message that was published at qos 2 will be sent at the qos of the subscription (as qos 2 can be downgraded to 0 or 1)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [22 February 2019 10:30 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/13 "2019-02-22T10:30:15Z")

</div>

no coconut yet again ☹  
But I was close 🙂

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [22 February 2019 23:33 UTC](https://discourse.nodered.org/t/mqtt-every-ten-seconds-question-multiple-clients/8203/14 "2019-02-22T23:33:41Z")

</div>

Thanks for the clarification. I had been under the wrong assumption that once set, the QOS doesn't change downstream.
