Ezlo MQTT plugin 1.0 connectivity issues

I’ve now setup a MQTT broker on my network and configured the plugin to connect to this broker. Yesterday evening things worked and messages were posted to the broker by meshbots, proving correct configuration of the plugin.

It didn’t take long to fail though, I now have connectivity issues from the plugin to the broker. I get the following errors in the logfiles:

2023-01-17 10:59:23.033095 INFO : Plugin started: ezlo.mqtt-1.0.0
2023-01-17 10:59:23.054556 INFO : init: GatewayPlugin: the gateway (ezlo.mqtt) got registered for the plugin (ezlo.mqtt-1.0.0)
2023-01-17 10:59:23.074881 INFO : Plugin: request to start the plugin (ezlo.mqtt-1.0.0, HUB:ezlo.mqtt/scripts/startup)
2023-01-17 10:59:23.134976 ERROR: sendExecutePluginScriptSync: return error as string: LuaInterpreter: Couldn't run a Lua code: [string "HUB:ezlo.mqtt/scripts/network/attempt_connect..."]:26: fail to make a connection (TCP) to a remote 192.168.100.2:1883 : AsyncSocket: fail to establish the connection by some local reason

How to proceed? Oh, of course I checked connectivity to the broker, my laptop with MQTT Explorer is connected to the broker at the same time, so it’s live.

Hi @jouked , Is the problem persistent or it happens once in a while ?

It’s persistent, the connection does not recover, not even trough a hub reboot. I guess the only way to get it working again is to uninstall and reinstall the plugin for now.

We need to check the logs on your controller.
@SaraV can you help on this pls. Also pls create a ticker for the customer and continue tracking from there.
Lets get full logs. especially ha-luad.log. And set log level to TRACE and help customer to retest again pls.

Hello @jouked!

I have sent you a PM in order to validate some information for contact and troubleshooting purposes. Could you please check it and reply back at your earliest convenience?

Thank you.

FYI, I’ve replied to the PM.

Furthermore, I did some more logging. When booting the ezlo hub, I can see the following message in ha-extensions.manager.log:

2023-01-20 13:02:43.262914 ERROR: sendExecutePluginScriptSync: return error as string: LuaInterpreter: Couldn't run a Lua code: [string "HUB:ezlo.mqtt/scripts/network/attempt_connect..."]:26: fail to make a connection (TCP) to a remote 192.168.100.2:1883 : AsyncSocket: fail to establish the connection by some local reason

I checked on host 192.168.100.2 (my mqtt broker) what’s happing on the network side, tcp port 1883, using tcpdump. For whatever reason, nothing is showing.

I digged a bit further, and surprisingly, not even the ARP request from the ezlo hub shows hub. Examining the ARP table on the ezlo hub also shows that no entry is present for 192.168.100.2, the mqtt broker.

So it seems that the the _network.connect() function called from attempt_connection.lua fully fails here.

I note the error in the logfile follows startup of the hub pretty quickly. So maybe the network connect attempt happens before the underlying OS is fully finished in setting up the network. Let’s give this a try.

I edited the startup.lua of the mqtt plugin, I made the following changes:

local _timer = require("timer")

.
.
.


for device_id, _ in pairs(_G.server_addresses) do
--	loadfile("HUB:ezlo.mqtt/scripts/network/attempt_connection"){
--		device_id = device_id,
--	}
	local timer_id = _timer.set_timeout(10000, "HUB:ezlo.mqtt/scripts/network/attempt_connection",{ device_id = device_id })
end

So I introduced a 10 second delay before trying the network connection. And hey, it works! That explains why it worked directly after installing the plugin, but it failed after the first reload.

So over to the plugin devs: it’s probably not right to introduce this delay, handling connection retry attempts would be much better. Furthermore, add reboot scenario’s to your testing procedures.

Looking forward to a 1.1 version of the plugin!

1 Like

Thank you for your feedback @jouked!

We’ve created an ECS ticket to keep tracking this issue and hopefully provide a solution soon. You can track this ticket by clicking here.

In case you need further assistance with anything else, let us know!