MQTT Broker keeps stopping working

pgershon
Posts: 534
Joined: Sat Jul 10, 2004 1:07 am

MQTT Broker keeps stopping working

Post by pgershon »

HI:

I recently started having issues with my Indigo / Shelly MQTTNG devices. It seems that periodically my devices lose their communication with MQTT, or the queue gets too large, or something else. I use MQTT explorer to see if things are working as test with the Shelly website or communicating with the Shelly devices directly via browser with their IP address.

I am always able to control the Shelly devices via website, but the MQTT "messages" stop appearing in MQTT explorer and Indigo does not see them. I have tried disconnecting and reconnecting MQTT explorer but it does not seem to help. I then go to Indigo and reload MQTT connector and MQTT broker, often several times. Eventually I see messages pop up in MQTT explorer and functionality everywhere is restored.

The problem started when I realize that the most recent update to to the plugin ShellyNGMQTT had been installed. Not sure when that happened but it removed the medications I had made to the prior version of the plugin to include functionality for my Shelly wall dimmer devices. I did this initially about 1.5-2 years ago and it had worked nicely (I believe I simply added to the devices.xml file and added a device for the dimmer, but its possible I did something else). In any case, I can no longer get my dinners to work with the plugin. I tried reverting to the older version of plugin that had my modification, but that failed. I now suspect I did something in there with Python 2 and it was not corrected.

The reason I am writing here is that every time I reload or otherwise tinker with the ShellyNGMQTT plugin, it breaks all MQTT communication regardless of Indigo, as I described above. Any thoughts or recommended steps toward diagnosis? Thanks
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: MQTT Broker keeps stopping working

Post by FlyingDiver »

The only thing I can think of (from my side) is to use a different MQTT broker (like Mosquitto) and see if the problems persist.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: MQTT Broker keeps stopping working

Post by MarcoGT »

I had the same problem and I solved it by switching to an external MQTT broker (Mosquitto)
odavis
Posts: 60
Joined: Fri Jan 14, 2011 6:31 pm
Location: El Cerrito, CA

Re: MQTT Broker keeps stopping working

Post by odavis »

I've just started playing with MQTT the past few days and only have one Shelly Pro 1 which I'm using to turn a pump on and off.

Coming up to speed on MQTT has been a bit but I'm starting to get the hang of it and I really appreciate having all these plugins that make it easy to add the capability to Indigo.

Thanks, FlyingDiver!

The first time I got things working it was sort of a surprise...oh...it's working! I wasn't 100% sure how I had done it. The next day the broker was disconnected and I decided to create things again using Aaronlionsheep's steps here viewtopic.php?p=211934#p211934

This got things working and my understanding improved a bit.

The next day (this morning) I awoke to the broker being red and disconnected again. It wasn't obvious how to fix it..ultimately I got it working through a combo of restarting the Mac, Indigo, plugins, and recreating the broker and trigger. Basically shake the whole mess until it starts again.

When it the broker goes into disconnect I can still operate the Shelly from its web page and I still see MQTT traffic in MQTT explorer. The issue is definitely somewhere in the Indigo / plugin nexus.

After the first incident I enabled debug logs for MQTT Broker so I have some entries to look at for the most recent disconnect. I summarize these below.

When I scan the logs for issues what I see are:

Healthy pattern:

Code: Select all

025-06-01 02:03:00.467	ShellyNGMQTT	sent "tub pump Switch" off
2025-06-01 02:03:00.467	MQTT Connector Debug	new device: processReceivedMessage: shellies-ng/shellypro1-ec6260ad5ef8/rpc
2025-06-01 02:03:00.468	MQTT Connector Debug	shellies-ng: type = topicMatch, broker = 1554423939
2025-06-01 02:03:00.468	MQTT Connector Debug	shellies-ng: Matching complete, is_match = True
2025-06-01 02:03:00.469	Trigger	shellies-ng
Then there's an unhealthy pattern where I can see OFF being sent but there aren't any MQTT connector entries. Then I might see some of these:

Code: Select all

2025-06-01 02:04:19.654	MQTT Connector Error	new device: Disconnected with result code 16
2025-06-01 02:04:19.662	MQTT Connector Error	new device: Disconnected with result code 16
And after some random time see a bunch of MQTT Connector entries that seem to be "catching up":

Code: Select all

2025-06-01 02:13:33.703	Trigger	shellies-ng
2025-06-01 02:13:33.706	MQTT Connector Debug	new device: processReceivedMessage: shellies-ng/shellypro1-ec6260ad5ef8/rpc
2025-06-01 02:13:33.708	MQTT Connector Debug	shellies-ng: type = topicMatch, broker = 1554423939
2025-06-01 02:13:33.709	MQTT Connector Debug	shellies-ng: Matching complete, is_match = True
Last night the unhealthy pattern repeated for hours (no MQTT Connector entries) and finally there was this:

Code: Select all

2025-06-01 08:35:22.308	ShellyNGMQTT Error	Error in plugin execution runConcurrentThread:

  File "plugin.py", line 85, in runConcurrentThread
type: ServerCommunicationError -- timeout waiting for response

2025-06-01 08:35:25.062	ShellyNGMQTT Error	plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
2025-06-01 08:35:25.883	ShellyMQTT Error	Error in plugin execution runConcurrentThread:

  File "plugin.py", line 330, in runConcurrentThread
type: ServerCommunicationError -- timeout waiting for response
These entries are about the time I logged in and began restarting plugins so the log gets a little busy with extra info that I"m unsure how to report here. However there was one additional error about a missing key in a database which might provide a clue:

Code: Select all

2025-06-01 08:46:45.760	MQTT Connector Error	Error in plugin execution ServerReplacedElem:
  File "plugin.py", line 116, in deviceUpdated
  type: key id 1554423939 not found in database
...and that key is the same as the MQTT Broker ID. By the time I get things working again it's with a new broker that has a different ID. So it seems there might be some corruption occurring along the way either in causing the issue or as part of attempting to fix the issue.

I reviewed my indigo setup for any scheduled items that might run near the time MQTT stops processing but didn't find anything at all scheduled.

I'm happy to DM the full event log if that would help.

Cheers,

Owen
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: MQTT Broker keeps stopping working

Post by FlyingDiver »

The MQTT Broker plugin is unstable. The code it uses appears to have been abandoned and I don't expect I'll ever have the time to rewrite it. I should probably discontinue the plugin.

I would recommend trying a different MQTT Broker. Using Mosquitto in a Docker container is probably the easiest solution.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
odavis
Posts: 60
Joined: Fri Jan 14, 2011 6:31 pm
Location: El Cerrito, CA

Re: MQTT Broker keeps stopping working

Post by odavis »

Thanks for the quick reply!

I’ll check out Mosquito
Post Reply

Return to “MQTT”