So given my track record: I am not getting it. aka: I'm stupid.
I have turned this machine off/on a few times since writing the flow in question and others.
I have injected the test messages. Looking at the MQTT node, the retain is NOT ticked.
Yet, when I turn on THIS machine and load the browser, I am getting messages given to me I injected 3 hours ago.
Some behaviour I observed on the broker, if the initial (first) message had a retain flag, it will keep it retained, until removed (I could be wrong but it is what I see on the broker).
@flecoufle. Um, Yeozers! I'll have to think about that as I am not good at reading the template.
As far as I know there is no $user or $passowrd. (pwd)
Stupid me, I wiped the messages.
Loading MQTT-explorer shows none of the messages.
I know (have a good idea) of those messages. They weren't there/shown.
So I don't get how that works.
I have seen other messages and their retain flag is set. Easy to see.
So it is a real curve ball for me.
I don't want to have to reboot/restart to get it to happen for the sake of seeing it.
I will have to try and remember to check next time I boot.
Oh! The message/s are seen on three different machines. So it isn't that a particular machine is deciding to be difficult.
The retain flag is only set on messages that are delivered by the broker for clients that connect late., (after the message has been sent to the broker - eg reconnecting). IE so you know the message is not "live". If the client is already subscribed and receiving data then even if the message is sent with the flag set (and thus held by the broker) - it is then delivered to the client without the flag set (as at that point it is currently live data).
Yes, I can accept that.
So maybe what I am asking is beyond Node-Red's scope.
If I send a message without retain set to false or true. . . . . . Though MQTT will send the message, what will happen if I send a message to a topic (channel) and later on connect/power up a machine which is also subscribed to the topic?
Will the message be sent to it obeying the retain or not?
I don't mind either way. It is just after having that mentioned (again) and refreshing my memory, it raises the question of why is the machine I just powered up getting messages from hours ago when theretainisn't set to either on the node?
I am not saying it needs to be forced to one or the other.
But maybe the effects of having it blank explained.
Yeah, ok that's a MQTT thing rather than a NR thing.
I'm just blabbing / thinking aloud.
I know that isn't always a good thing, but.
the defaults are retain=false and QoS=0... it doesn't require any more thinking about than that. The default means it is taken care of if you don't set it.
One thing that may be confusing you is that if you once publish to a topic with Retain set then that will not be un-retained by publishing with Retain not set. So a client subscribing at any time later will be sent a value. To remove it you have to publish with null contents as described earlier.