I have recently came across an issue with the MQTT nodes on node Red.
The node red server is set up on an AWS server,
since 2 months I have a problem that MQTT node every now and then (once every 4 days, every 5 days, the last 2 weeks) disconnects and refuses to connect to restart node-red or deploy.
In the meantime nothing is done on the node-red itself so this is not a problem caused by deploy. Node red as of today is in the latest version.
I don't want to sound like a broken record but I have had similar problems and it was a bad power supply.
What kind of power supply are you using?
You may want to check logs (sorry I can't tell you which ones or where they are) and see if it is only the MQTT that is failing or the entire machine - if it is a RasPi.
Broker nor power supply is not the problem I already checked it at the beginning.
The logs look like this which makes them not very helpful :/.
5 Dec 07:45:07 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:22 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:22 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:37 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:37 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:52 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
5 Dec 07:45:52 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://q25a-ats.iot.eu-central-1.amazonaws.com:8883
I only mentioned the power supply because it cost me 8 months of chasing my tail trying to work out what was going on.
Can you confirm the uplink is always available when needed?
Is it WiFi or Cable?
Though even if it is cable: if the network goes down: it is down. Just WiFi is (can be) more prone to dropouts than cable.
thanks for your help but I doubt this is the solution
everything is on AWS as a test version, the data itself is also collected separately for comparison because so far I am testing it, so I rule out a problem with the power broker or wifi.
maybe my node red configuration is wrong but if that's the case I don't understand why it works for a few days/weeks and then stops at random intervals
That is slightly worring. Not in a BAD way, but to me that means (or could) that there is something else causing the problem.
Power spikes. (or drops)
EMP (or similar).
RF interference.
But as I said, I am out of my depth.
Please don't rule things out. I learnt this the hard way.
I stubbornly believed the power supply was good.
In the end I replaced 2. On two RasPis and things have since been great.
Maybe the keep alive (on the channel) time is expiring?
I did not rule out a problem with the broker but to have a clear conscience I just checked the base collected outside nod red,
And there are no problems.
Keep alive is set at 60 which I still think is a bit much, do you think it should be more?
I left the client id blank for autamatic gereation
Oh, which version of MQTT are you using?
The latest?
As much as I don't like hearing this: It could be you have an older version and so the bug exists.
I don't know how to get this information either, sorry.
But may be worth checking.
On another project I helped out with, that had issues with AWS + dynamic subscriptions, MQTT V5 was supported (not all V5 features were supported - but everything V3.11 does was) - this helped greatly.
The easy way is "try it" a V5 connection wont connect if the broker doesnt support it! Thats the easy test.