MQTT in randomly disconnect


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.


cliend id is empty

On the graph you can see that it did not work from 22 the previous day until today the moment of reboot

Do you have any ideas what could be the reason for this?

On what is the MQTT broker running?

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.

Sorry I can't be of more help.

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://

5 Dec 07:45:22 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://

5 Dec 07:45:22 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://

5 Dec 07:45:37 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://

5 Dec 07:45:37 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://

5 Dec 07:45:52 - [info] [mqtt-broker:Aws i] Connected from broker: mqtts://

5 Dec 07:45:52 - [info] [mqtt-broker:Aws i] Disconnected from broker: mqtts://

I think I am out of my depth.

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

Above me.

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.

Give me a momentnet, I'll check it out.

You may also want to post the version of NR you are using and on which kind of computer/OS it is running.

I'm using node-red version 3.0.2

The MQTT node is in the core node red if I understand correctly so the MQTT version is the node red version

its runing on amazon AWS

3.1.1 is what I have.
That is seen here:


then I have the same

1 Like

Ok, that is good.

NR version is here:

Machine? O/S?

(My eyes are getting heavy. I'm going now. Too tired.)
I hope someone else can help you more than I have.

on linux

Do you use any dynamic subscriptions?

Can you try switching to Broker type v5 (I believe you will get richer disconnection info)

I don't quite understand what you mean by "dynamic subscriptions"?

I have to check if AWS supports version 5
I was using 3 because it was the most "stable"

Also, does that continue connecting and disconnecting until you rebooted?

Did you try a node-red restart?

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.

Yes, until node-red restart
I was doing always a restarts because it didn't require logging in to AWS node reda.