MQTT Broker - Connection failed?

Posted on
Tue Aug 06, 2019 10:31 am
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

MQTT Broker - Connection failed?

I have just gone through and completed the arduous task of converting and moving all my MQTT publishing to this plugin (previously using mqttGateway).

I deleted my existing copy of mosquitto (previously installed using Homebrew).

I ticked the check_box in the plugin config: Run MQTT Server.

However, I am getting a connection failed message and none of my MQTT messages are working.

They were working because I suspect that mosquitto was running in the background (I didn't check) and the failure happened once I did a reboot of my iMac to double check everything was going to work - which it now doesn't. :shock:

I am beginning to think I might have done the wrong thing in deleting mosquitto and that I have misunderstood what that check_box means?

Does the plugin provide an all-in-one solution? :)

Posted on
Tue Aug 06, 2019 1:57 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

You do realize this is alpha-level code? Everything is marked pre-release.

Yes, it's all-in-one, but I don't guarantee it'll do everything exactly like the other plugins.

That said, there was a timing issue in early versions. I think it's fixed in the latest (0.0.5). Are you running that one?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Aug 06, 2019 3:44 pm
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Broker - Connection failed?

FlyingDiver wrote:
You do realize this is alpha-level code? Everything is marked pre-release.


Yes of course, just trying to help with testing - I wasn't complaining. :D

FlyingDiver wrote:
Yes, it's all-in-one, but I don't guarantee it'll do everything exactly like the other plugins.

That said, there was a timing issue in early versions. I think it's fixed in the latest (0.0.5). Are you running that one?


Yes, I am running 0.0.5 :)

The plugin log says it is starting mosquitto but I can't see any mosquito processes running (not sure whether I should though)?

Posted on
Tue Aug 06, 2019 4:10 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

If you have the box checked, and restart the plugin, the process should be running. Something like:

Code: Select all
Kraken:~ user$ ps aux | grep mosq
user          77842   0.0  0.0  4290524   2184   ??  S     5:06PM   0:01.44 /Users/user/Projects/Indigo PlugIns/MQTT/MQTT.indigoPlugin/Contents/Server Plugin/mosquitto -p 1883


Check the permissions on the file. Maybe the round trip through GitHub is messing them up. But I'm pretty sure I tested that.
Code: Select all
Kraken:Server Plugin user $ pwd
/Users/user/Projects/Indigo PlugIns/MQTT/MQTT.indigoPlugin/Contents/Server Plugin
Kraken:Server Plugin user $ ls -l mosquitto
-rwxr-xr-x@ 1 user  staff  356700 Aug  2 10:52 mosquitto

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Aug 06, 2019 4:15 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

Of course, if it was me, I would have left the existing broker running and just duplicated the subscriptions and message handling in the new plugin to see how things worked. But in any case, what kinds of things did you end up doing? I have no idea what your previous infrastructure was, so I'm not sure what I need to do to make it easier for users to transition (if they want to).

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Aug 06, 2019 4:18 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

Also, when I started the project, I was using Mosquitto running in a Docker container on my Synology NAS. That was the fastest way for me to get one running. Then I implemented the internal one to make it easier on people who don't use Docker. And then my Docker one started giving me socket errors and disconnecting as soon as I published a message. After a few restarts it seems to have stopped doing that, but I'm still not sure why. So I'm mostly using the internal one for testing.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Aug 07, 2019 4:41 am
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Broker - Connection failed?

On grandson minding duties today and so have reinstalled Mosquitto via Homebrew and all is working again (via your plugin). :D

Will revisit this when all is calm here. :)

Posted on
Wed Aug 07, 2019 5:22 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

autolog wrote:
On grandson minding duties today and so have reinstalled Mosquitto via Homebrew and all is working again (via your plugin). :D

Will revisit this when all is calm here. :)


Please do. If the internal broker isn't going to run reliably on other systems, I need to take it out of the plugin. That was a convenience for users new to MQTT, not something that's really essential.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Aug 07, 2019 7:48 am
AndyVirus offline
Posts: 257
Joined: Mar 18, 2014
Location: Newport Pagnell, UK

Re: MQTT Broker - Connection failed?

I had same issue. I just re-started mosquito from homebrew i was using before. Now i know that it IS supposed to start a mosquito instance, i will try the suggested permissions above also.
Ill report back in a min

Posted on
Wed Aug 07, 2019 8:15 am
AndyVirus offline
Posts: 257
Joined: Mar 18, 2014
Location: Newport Pagnell, UK

Re: MQTT Broker - Connection failed?

OK so i can see a Mosquito server start but it does not accept connections. I have checked permissions and they look the same as yours.
It does not look like it is opening a port to listen on. Using "sudo lsof -i -P | grep -i "listen"" I can not see anything listening on 1883.

Posted on
Wed Aug 07, 2019 9:23 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

I just added code to log the Mosquitto server's stderr output to the plugin's log. So that should help figure out what's going on. I also added an option to turn on the server's verbose mode. Which will give you more info than you ever wanted.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Aug 07, 2019 10:02 am
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Broker - Connection failed?

OK, Installed 0.0.6 and got this in the log when I enabled the MQTT server:
Code: Select all
2019-08-07 16:56:29.171   [    INFO]               Plugin.deviceStopComm           Flying Diver MQTT: Stopping Device
2019-08-07 16:56:29.173   [    INFO]               Plugin.shutdown                 Shutting down MQTT
2019-08-07 16:56:31.709   [    INFO]               Plugin.startup                  Starting MQTT
2019-08-07 16:56:31.715   [    INFO]               Plugin.deviceStartComm          Flying Diver MQTT: Starting Device
2019-08-07 16:56:31.715   [THREADDEBUG]               Plugin.deviceStartComm          Flying Diver MQTT: Device is current version: 0
2019-08-07 16:56:31.716   [   DEBUG]        Plugin.Broker.__init__                 Flying Diver MQTT: Broker __init__ address = localhost, port = 1883, protocol = 3, transport = tcp
2019-08-07 16:56:31.736   [   DEBUG]        Plugin.Broker.on_connect               Flying Diver MQTT: Connected with result code 0
2019-08-07 16:57:19.406   [   ERROR]        Plugin.Broker.on_disconnect            Flying Diver MQTT: Disconnected with result code 1
2019-08-07 16:57:51.382   [    INFO]               Plugin.deviceStopComm           Flying Diver MQTT: Stopping Device
2019-08-07 16:57:51.383   [    INFO]               Plugin.shutdown                 Shutting down MQTT
2019-08-07 16:57:54.377   [    INFO]               Plugin.startup                  Starting MQTT
2019-08-07 16:57:54.377   [    INFO]               Plugin.startup                  Starting mosquitto MQTT server
2019-08-07 16:57:57.458   [    INFO]               Plugin.deviceStartComm          Flying Diver MQTT: Starting Device
2019-08-07 16:57:57.459   [THREADDEBUG]               Plugin.deviceStartComm          Flying Diver MQTT: Device is current version: 0
2019-08-07 16:57:57.460   [   DEBUG]        Plugin.Broker.__init__                 Flying Diver MQTT: Broker __init__ address = localhost, port = 1883, protocol = 3, transport = tcp
2019-08-07 16:57:57.478   [   DEBUG]               Plugin.runConcurrentThread      (mosquitto) dyld: Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
2019-08-07 16:57:57.582   [   DEBUG]               Plugin.runConcurrentThread      (mosquitto)   Referenced from: /Library/Application Support/Perceptive Automation/Indigo 7.3/Plugins/MQTT.indigoPlugin/Contents/Server Plugin/mosquitto
2019-08-07 16:57:57.686   [   DEBUG]               Plugin.runConcurrentThread      (mosquitto)   Reason: image not found

Posted on
Wed Aug 07, 2019 10:23 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Broker - Connection failed?

Interesting. /opt/local is where the Ports application installs things. Ports is an alternative to Brew. So my system already had that, and yours doesn't.

I'm not sure it's worth my effort to find all the dependencies and fix this. Is having a built-in MQTT broker that important? A production server really ought to have authentication and so on. It's easy enough to install one using Brew or Ports or Docker. And if you're trying to communicate with devices outside the local LAN, a cloud based one would be even better. I spun one up in a Docker container on a Digital Ocean droplet in under 15 minutes. Which is pretty sweet for $5/month.

Thoughts?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Aug 07, 2019 10:34 am
AndyVirus offline
Posts: 257
Joined: Mar 18, 2014
Location: Newport Pagnell, UK

Re: MQTT Broker - Connection failed?

I got the same. I personally dont mind either way if the plugin provides the broker or not, one less thing for me to remember to update but thats the only benefit for myself being combined.

Code: Select all
Starting plugin "MQTT 0.0.6" (pid 51840)
   Started plugin "MQTT 0.0.6"
   MQTT                            Starting MQTT
   MQTT                            Starting mosquitto MQTT server
   MQTT                            MQTT Broker: Starting Device
   MQTT Threaddebug                MQTT Broker: Device is current version: 0
   MQTT Debug                      MQTT Broker: Broker __init__ address = localhost, port = 1883, protocol = 4, transport = tcp
   MQTT Debug                      (mosquitto) dyld: Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
   MQTT Debug                      (mosquitto)   Referenced from: /Library/Application Support/Perceptive Automation/Indigo 7.3/Plugins/MQTT.indigoPlugin/Contents/Server Plugin/mosquitto
   MQTT Debug                      (mosquitto)   Reason: image not found

Posted on
Wed Aug 07, 2019 10:50 am
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Broker - Connection failed?

Probably not worth spending your time as I can see it potentially causing problems down the line with you having to keep it up-to-date. :)

Who is online

Users browsing this forum: No registered users and 2 guests