Page 1 of 3

MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 9:51 am
by boisy
I'm seeing an issue with my MQTT connector devices. At times, they appear to disconnect from my localhost MQTT broker. Once disconnected, I have to check and recheck the "Comm Enabled" checkmark to kick the connector back to the connected state.

Why doesn't the connector attempt to reconnect to the broker?

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 10:14 am
by FlyingDiver
What broker?

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 11:54 am
by Colly
I highlighted similar issues previously, see topic viewtopic.php?f=316&t=26487. I never followed up any further with Joe.
I have a trigger that restarts the connector once it disconnects. It can happen quite often, sometimes 2 - 3 times a day with no obvious link to other activity on the network. Looking back right now the last time was yesterday morning, nothing today as of yet.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 12:05 pm
by boisy
Joe,

I'm using your MQTT broker plugin, so it's all local.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 12:10 pm
by cuhouse
I had a similar issue back Sept 2019 but was resolved here
https://github.com/FlyingDiver/Indigo-MQTT/issues/4/

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 12:58 pm
by Colly
cuhouse wrote:
I had a similar issue back Sept 2019 but was resolved here
https://github.com/FlyingDiver/Indigo-MQTT/issues/4/

I think this only happened in more recent versions of the plugin for me. I'm wondering did that resolution get lost in later versions - probably not as you don't appear to have any recent issues.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 1:46 pm
by FlyingDiver
boisy wrote:
Why doesn't the connector attempt to reconnect to the broker?


Honestly, because it's usually a broker problem, so just blindly attempting to reconnect isn't the solution.

I have not seen any issues with frequent disconnects with the Broker plugin. If this is happening often, please open a GitHub issue with logs from both the Broker and Connector plugins.

You might want to trigger on changes to the Connector status so you get an alert when this happens. You could also restart the Connector device when it happens.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 2:43 pm
by boisy
Thanks Joe. I've setup a trigger to notify me the next time this occurs. I'll try to establish rhyme and reason.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 7:02 pm
by boisy
Joe,

One thing I have noticed is that when I restart my iMac and Indigo launches, the connectors are in "Connection Failed" state. Looking at the log, it appears the MQTT Connector plug-in starts before the MQTT Broker. It would appear the order of the plug-in stating might affect this?

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 7:34 pm
by FlyingDiver
What version of Indigo you running? It shouldn't be doing that. There was a recent change to the plugin API to provide startup order hints.

Re: MQTT Connectors disconnect

PostPosted: Wed Jan 18, 2023 7:36 pm
by FlyingDiver
Well darn, it's doing it on my dev system too. I need to check the hints and then report that to the guys.

Re: MQTT Connectors disconnect

PostPosted: Thu Jan 19, 2023 8:16 am
by FlyingDiver
OK, so I confirmed the plugins are starting in the correct order. The problem is that it takes longer to spin up the broker than it does a connector device. So the connector is trying to connect before the broker is actually accepting connections. I'll have to figure out a fix for this.

Re: MQTT Connectors disconnect

PostPosted: Thu Jan 19, 2023 10:59 am
by boisy
Thanks Joe. You're doing the Lord's work!

Re: MQTT Connectors disconnect

PostPosted: Thu Jan 19, 2023 11:28 am
by FlyingDiver
Version 2022.1.0 of the MQTT Connector plugin now on the plugin store. This version adds a delay field to the "Connection Info" tab of the device configuration dialog. Setting this to 3 or 4 seconds will give the Broker time to get running.

Re: MQTT Connectors disconnect

PostPosted: Thu Jan 19, 2023 12:29 pm
by boisy
I just set this to 5 seconds for my connectors, quit the server, restarted it, and now it comes up connected after the delay. Very good!