MQTT Node frequently connect disconnect with azure iothub

Hello Experts

I am facing issue mqtt connection issue. I am creating mqtt object in function node, I dont see way to disconnect or destroy mqtt connection, on redeploy of flow when I try connect method its get connected but seems like in memory there are two mqtt connection get created hence there is race condition in both to acquire connection. If I restart node and then try connection it works well

So is there way to disconnect existing mqtt connection? Is there any other way to dispose mqtt object? The way it does when restart node?

This is my flow.

Hi and welcome.

As you are DIY (doing it yourself) in a function node instead of using the built in MQTT nodes, it is difficult for regular users to help. I can clearly see what your issue is but would take me a fair bit of time to explain and is ultimately pointless as the the built in MQTT node supports dynamic connect/disconnect (as is documented in its built in help) - you should try that before asking about a DIY solution.

Actually with mqtt node I was facing same issue so was trying with DIY

Here is with mqtt node, it keep switching connect/disconnect.

There is a number of fixes in Node-RED v3.0.0-beta.3 around MQTT (and will eventuially make it into Node-red 2.x stream)

So perhaps you might want to try the beta?

Will try that for sure, but existing system having 2.x will have this issue right?

Maybe. Maybe not. All I can say is that in certain circumstances the MQTT node can get locked up for various reasons. I don't know what you did so cannot say for certain if the fixes cover your use case. What I can say is that it is much more stable in v3 beta.

ok no problem. For my it seems like some issue, as I have created simple flow having mqtt connection, it works will until I do some changes in deploy. The only thing is my mqtt node dynamic and its not auto connected. Same thing with DIY. In both case I see same behavior.

I will try with v3 beta and post here conclusion, hopefully it will be positive :slight_smile:

Imran

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.