openLuup: MQTT server
-
I'm wonder if the first error messages you shown are simply the fact that you have MQTT Inspector running on an, essentially, unattended machine, and it just goes to sleep for a while... I know that this is exactly what mine does.
I've become fairly convinced that these errors are something deep within the LuaSocket library. I've always have something like this from time to time, be it the HTTP server, or MQTT now, or other things. I doubt that this is directly related to your 'crash' (freeze?) but I wouldn't rule out a network issue.
I've just reloaded my main openLuup instance (running on Synology Docker) for a system updata, and that's been rock solid for the last 50 days, which is not unusual for all the openLuup systems I used to run.
-
@akbooer said in openLuup: MQTT server:
I'm wonder if the first error messages you shown are simply the fact that you have MQTT Inspector running on an, essentially, unattended machine, and it just goes to sleep for a while... I know that this is exactly what mine does.
I think you are correct, I have seen similar error messages before and as you said I had Mqtt Explorer running on my PC over night.
I've become fairly convinced that these errors are something deep within the LuaSocket library. I've always have something like this from time to time, be it the HTTP server, or MQTT now, or other things. I doubt that this is directly related to your 'crash' (freeze?) but I wouldn't rule out a network issue.
I've just reloaded my main openLuup instance (running on Synology Docker) for a system updata, and that's been rock solid for the last 50 days, which is not unusual for all the openLuup systems I used to run.It sounds reasonable that it could be something socket related, it looks like it on the errors. I wonder if the fact that I have my Zway server on another server could be the reason for these socket errors and the crashing/freezing. I assume that there is a lot of communication between the bridge and the zway server. My old server was rock solid before I set up Mqtt, perhaps the added load on the sockets gets too high at times.
-
If you don't have to run MQTT Inspector, then don't! It subscribes to all messages and that certainly increases traffic.
-
@akbooer said in openLuup: MQTT server:
If you don't have to run MQTT Inspector, then don't! It subscribes to all messages and that certainly increases traffic
@akbooer I have now been running my Pi server for 26 days without any crashes. So far, so good!
Version 21.8.16 seems to give less errors in the log (almost none in fact) and also to be more stable.
I also have taken note not to have MqttExplorer up and running to lessen the load.Yesterday just for fun I set up Home Assistant Supervised. I managed to get it up and running of an old Athom PC with Ubuntu and Docker on.
Something new to learn.
I will also test MSR of course when I have got the grip of HA.A related topic to the Mqtt load above is that in HA there is a Mqtt Integration that I thought could be interesting to test together with OpenLuup.
The question is if anyone is using this together with OpenLuup as broker and if this would have the same risk of (over)loading the traffic on the OpenLuup server?
In other words not to use Mosquitto but instead the OpenLuup broker to get some of the published info into HA.
Or if there is a better way of doing this? -
I guess the answer is "it depends"... most notably on what you choose to let HA subscribe to.
-
@akbooer yes that makes sense of course!
If I have understood it right you do it in two steps in HA, step one is to point it to the broker and step two is then to add Mqtt devices.
In other words I hope that the first step does not then subscribe to "everything" as MqttExplorer perhaps does. -
I was seeing similar network issues and also came to the conclusion that the socket library was most likely at fault. My solution is to use Mosquitto as my main broker, which accepts all MQTT traffic (topic # in 0) with all my MQTT devices pointing to it, and then Mosquitto filters push traffic to openLuup. Below is my config file that displays the filters:
allow_anonymous true password_file /mosquitto/data/PW.txt listener 1883 connection openLuup address 127.0.0.1:1882 topic tele/# out topic stat/# out topic BlueIris/# out topic # in 0 cleansession false notifications true username ***** password ******* bridge_protocol_version mqttv311 try_private false log_timestamp true log_timestamp_format %Y-%m-%d--T_%H:%M:%S
As you can see, Mosquitto runs on the same server as openLuup. It is started by a docker compose file. The config filters eliminated the network errors on openLuup and my openLuup install now runs for days on end without any errors at all. I also have HA running on the same server via docker compose, though I only use it for its Hacs Alexa integration. I pipe my Alexa calls to HA using an HA token and a crude plugin that I wrote. I have not found a use for HA outside of openLuup yet, though there are some interesting integrations I will eventually try out.
As regards MQTT I don't think you need to worry about network traffic so much as mqtt is an extremely light protocol, at least in so far as compared to cameras and hi-def wireless etc ( I have a bunch of these high bandwidth devices on my network in their own subnets). I have found that the thing that tends to bog down is the lua socket function and as long as you limit its connections, you will probably alleviate most of the network problems.
Nginx is one of the best web servers available, specializing in load balancing millions of connections, and from what I've read, it is written in Lua. Which suggests that the lua socket module itself is causing the network issues as Nginx most likely rolled their own network library.
-
@buxton said in openLuup: MQTT server:
from what I've read, it is written in Lua.
It's written in C. And the BSD socket library that underpins the Unix/Linux versions is time-tested and battle-hardened. It could never be Lua, IMO, as the true multithreading/multitasking required is not a feature Lua possesses (and thus places a limit on Lua's socket handling).
-
luasocket definitely has limitations... I have investigated replacements in the past and never found one with sufficient maturity. There are many projects on the side attempting to improve on it. At the end I just updated the library to the latest on github.
Here is one example:
-
@toggledbits ah OK. Then I'm confusing the dev with lua scripts used within nginx.
-
@buxton said in openLuup: MQTT server:
I was seeing similar network issues and also came to the conclusion that the socket library was most likely at fault. My solution is to use Mosquitto as my main broker, which accepts all MQTT traffic (topic # in 0) with all my MQTT devices pointing to it, and then Mosquitto filters push traffic to openLuup. Below is my config file that displays the filters:
@Buxton thank you for the good advice!
I tried to set up the Mqtt integration in HA by directing it to the Mqtt address (mqtt://ipadress, port, user and passwd) on my OpenLuup, but it does not work. It just says "failed to connect" every time. Perhaps it only works with Mosquitto? Makes it a bit more complicated all by a sudden. I will see if I can try something in the direction of what you have set up later.I have not found a use for HA outside of openLuup yet, though there are some interesting integrations I will eventually try out.
I am in the same situation, no use at the moment, just a bit interested to see how it works. As you say there seem to be some interesting integrations there. Also there are more possibilities to present various information on the HA dashboard that could be nice for some use cases maybe. ESPHome also looks a bit interesting as a complement to Tasmota.
One use case that could be of interest to get into HA (in combination with ESPHome) is the energy metering of the house.As a sidenote my Shelly devices integrated really nicely into HA without affecting the Mqtt integration to OpenLuup.
-
I got the setup in HA to work so that it uses the OpenLuup Mqtt broker.
Instead of using the "Configuration->Integrations->Add Integrations->Mqtt" way that just gave an error message every time, I added it manually in the configuration.yaml file by simply adding:
mqtt: broker: ipadress port: 1883 username: user password: passwd
After a restart it works. I have tested both to send a test message from HA to OpenLuup and also creating a few sensors in HA that subscribe to a topic from a Tasmota device on the broker in OpenLuup.
I still have no use case for it at the moment, but at least I learnt something on the way.
-
Trying to look at @Crille 's report, updated my openLuup to the latest (development branch), started up, MQTT server doesn't appear to be running... can't connect and netstat reports nothing open on 1883. What do I need to do to get it running? Is there a configuration guide?
-
MQTT server doesn't appear to be running...
Have you assigned it a port?
local attr = luup.attr_set do -- enable MQTT attr ("openLuup.MQTT.Port", 1883) attr ("openLuup.MQTT.Bridge_UDP", 2883) -- UDP bridge attr ("openLuup.MQTT.PublishVariableUpdates", true) -- publish every variable update attr ("openLuup.MQTT.PublishDeviceStatus", 2) -- publish a single device status every N seconds (0 = never) end
-
…documentation was in this release note…
2020 Release 10.2
-
Excellent, thanks! On first blush, it looks like the service isn't closing connections completely on restart/shutdown; they stay open for a minute or so and then time out. Not sure if that's related, but may need a look.
Also I can't connect my Home Assistant 2021.11.5 to the broker. This in the logs:
2021-11-24 09:59:41.248 openLuup.io.server:: MQTT:1883 connection from 192.168.0.10 tcp{client}: 0x561b1d43bdb8 2021-11-24 09:59:41.249 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x561b1d43bdb8 2021-11-24 09:59:41.249 openLuup.mqtt:: CONNECT: Unknown protocol name: 'MQIsdp' tcp{client}: 0x561b1d43bdb8 2021-11-24 09:59:42.255 openLuup.io.server:: MQTT:1883 connection from 192.168.0.10 tcp{client}: 0x561b1d4499a8 2021-11-24 09:59:42.256 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x561b1d4499a8 2021-11-24 09:59:42.256 openLuup.mqtt:: CONNECT: Unknown protocol name: 'MQIsdp' tcp{client}: 0x561b1d4499a8 2021-11-24 09:59:44.262 openLuup.io.server:: MQTT:1883 connection from 192.168.0.10 tcp{client}: 0x561b1d4630c8 2021-11-24 09:59:44.263 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x561b1d4630c8 2021-11-24 09:59:44.263 openLuup.mqtt:: CONNECT: Unknown protocol name: 'MQIsdp' tcp{client}: 0x561b1d4630c8 2021-11-24 09:59:57.907 openLuup.io.server:: MQTT:1883 connection from 192.168.0.10 tcp{client}: 0x561b1d501108 2021-11-24 09:59:57.907 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x561b1d501108 2021-11-24 09:59:57.908 openLuup.mqtt:: CONNECT: Unknown protocol name: 'MQIsdp' tcp{client}: 0x561b1d501108 2021-11-24 09:59:58.913 openLuup.io.server:: MQTT:1883 connection from 192.168.0.10 tcp{client}: 0x561b1d50e638 2021-11-24 09:59:58.914 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x561b1d50e638 2021-11-24 09:59:58.914 openLuup.mqtt:: CONNECT: Unknown protocol name: 'MQIsdp' tcp{client}: 0x561b1d50e638
-
@toggledbits said in openLuup: MQTT server:
Also I can't connect my Home Assistant 2021.11.5 to the broker. This in the logs:
Looks like it is using a modified protocol name MQIsdp rather than the default MQTT.
At the moment, it's not configurable on the openLuup side (but, of course, it could be.) Can you change this in HA?
-
toggledbitswrote on Nov 24, 2021, 3:22 PM last edited by toggledbits Nov 24, 2021, 10:28 AM
@akbooer doesn't appear to have an option to change it:
On the other issue, my MQTT library is attempting to reconnect, but this is the only thing logged:
2021-11-24 10:05:18.394 openLuup.io.server:: MQTT:1883 connection from 192.168.0.66 tcp{client}: 0x55e743b50ef8
There are no other messages with that ID. Can I get some more debug out of the server somehow? The library on my end is the latest version of the MQTT library commonly used in NodeJS; it's been around for a long time, and works perfectly with Mosquitto and other brokers I've tried. Initial connection always works, it's just reconnects that fail, so clearly there is something between the two that's keeping some history and maybe altering connect behavior, but I have no idea what and no visibility into it (at the moment).
-
@toggledbits said in openLuup: MQTT server:
Can I get some more debug out of the server somehow?
attr ("openLuup.MQTT.DEBUG", true)
will write more detail to the log (and, IIRC, standard output.)
You've apparently not got and username/password credentials set. These can be configured under openLuup...
attr ("openLuup.MQTT.Username", "foobar") -- Password, etc...
-
Do credentials have to be set?