Closed ZoneMR closed 2 years ago
I have never seen this before. Can you post your config here? (Remember to hide any secrets)
It should be easy to replicate, as the issue happens whenever the MMM browser client is refreshed.
I don't believe my config has anything particularly unusual in it?
{
module: 'MMM-MQTT',
position: 'bottom_left',
header: 'Electricity',
config: {
logging: false,
useWildcards: false,
mqttServers: [
{
address: '192.168.68.200',
port: '1883',
subscriptions: [
{
topic: 'tele/garage/consumer-unit/SENSOR',
jsonpointer: '/ENERGY/Power',
label: 'Power',
suffix: 'kW',
divide: 1000,
decimals: 2,
maxAgeSeconds: 60,
colors: [
{ upTo: 0.5, value: "blue" },
{ upTo: 1, value: "#4080ff" },
{ upTo: 2, value: "" },
{ upTo: 5, value: "orange" },
{ upTo: 1000, value: "red" },
],
},
{
topic: 'tele/garage/consumer-unit/SENSOR',
jsonpointer: '/ENERGY/Today',
label: 'Today',
suffix: 'kWh',
decimals: 2,
maxAgeSeconds: 60,
colors: [
{ upTo: 20, value: "" },
{ upTo: 30, value: "orange" },
{ upTo: 1000, value: "red" },
],
},
{
topic: 'tele/garage/consumer-unit/SENSOR',
jsonpointer: '/ENERGY/Voltage',
label: 'Voltage',
suffix: 'V',
decimals: 0,
maxAgeSeconds: 60,
colors: [
{ upTo: 220, value: "blue" },
{ upTo: 250, value: "" },
{ upTo: 500, value: "red" },
],
},
{
topic: 'tele/garage/consumer-unit/SENSOR',
jsonpointer: '/ENERGY/Current',
label: 'Current',
suffix: 'A',
decimals: 1,
maxAgeSeconds: 60,
colors: [
{ upTo: 30, value: "" },
{ upTo: 50, value: "orange" },
{ upTo: 2000, value: "red" },
],
},
]
}
],
}
},
Ok, thanks. I am not sure when I get the time, but I will take a look at it.
I found time today :-) Version 1.1.1 has a fix for this. Please try it out. I just hope it does not have any side effects, but I think it will not. There were actually two bugs :-) One for making new connection on every refresh, and one for duplicating the servers on every refresh. Thank you for pointing this out.
Brilliant - thanks - fix tested and works for me 🙂
Every time the MMM browser client refreshes, multiple new connections are established to the mqtt server.
The first time the client loads, in response to MQTT_CONFIG, a single connection is made.
The second time, two new connections are made, in addition to the existing connection.
The third time, three new connections are made, in addition to the existing three.
I have my magic mirror set to auto-refresh every two hours, and the exponential opening of new connections causes the mqtt server to run out of available sockets and shit itself.
See log below, this what happens on the third client connection after startup:
Not explored in detail, but looks like there's some issue with deduplication in addServers and/or an issue where startClients doesn't consider client connections which have already been made.