hassio-addons / addon-mqtt

MQTT Server & Web client - Home Assistant Community Add-ons
https://addons.community
MIT License
35 stars 15 forks source link

1.0.0 does not start up with more than 1 mqttusers #34

Closed odtgit closed 5 years ago

odtgit commented 5 years ago

Problem/Motivation

After upgrade from 0.3.0 to 1.0.0 the MQTT Server does not start properly

Expected behavior

That it would work with the same config as previously (4 users). But only starts up with 1.

Actual behavior

trace log:

         end
        elif (.mqttusers[3].topics | type == "object") then
            if (.mqttusers[3].topics == {}) then
                empty
            else
                .mqttusers[3].topics
            end
        else
            .mqttusers[3].topics
        end
TRACE: bashio::config.true: mqttusers[3].readonly
TRACE: bashio::config: mqttusers[3].readonly
TRACE: bashio::jq: /data/options.json if (.mqttusers[3].readonly == null) then
            null
        elif (.mqttusers[3].readonly | type == "string") then
            .mqttusers[3].readonly // empty
        elif (.mqttusers[3].readonly | type == "boolean") then
            .mqttusers[3].readonly // false
        elif (.mqttusers[3].readonly | type == "array") then
            if (.mqttusers[3].readonly == []) then
                empty
            else
                .mqttusers[3].readonly[]
            end
        elif (.mqttusers[3].readonly | type == "object") then
            if (.mqttusers[3].readonly == {}) then
                empty
            else
                .mqttusers[3].readonly
            end
        else
            .mqttusers[3].readonly
        end
TRACE: bashio::var.true: false
TRACE: bashio::config: mqttusers[0].username
TRACE: bashio::jq: /data/options.json if (.mqttusers[0].username == null) then
            null
        elif (.mqttusers[0].username | type == "string") then
            .mqttusers[0].username // empty
        elif (.mqttusers[0].username | type == "boolean") then
            .mqttusers[0].username // false
        elif (.mqttusers[0].username | type == "array") then
            if (.mqttusers[0].username == []) then
                empty
            else
                .mqttusers[0].username[]
            end
        elif (.mqttusers[0].username | type == "object") then
            if (.mqttusers[0].username == {}) then
                empty
            else
                .mqttusers[0].username
            end
        else
            .mqttusers[0].username
        end
TRACE: bashio::config: mqttusers[0].password
TRACE: bashio::jq: /data/options.json if (.mqttusers[0].password == null) then
            null
        elif (.mqttusers[0].password | type == "string") then
            .mqttusers[0].password // empty
        elif (.mqttusers[0].password | type == "boolean") then
            .mqttusers[0].password // false
        elif (.mqttusers[0].password | type == "array") then
            if (.mqttusers[0].password == []) then
                empty
            else
                .mqttusers[0].password[]
            end
        elif (.mqttusers[0].password | type == "object") then
            if (.mqttusers[0].password == {}) then
                empty
            else
                .mqttusers[0].password
            end
        else
            .mqttusers[0].password
        end
TRACE: bashio::config: mqttusers[0].topics
TRACE: bashio::jq: /data/options.json if (.mqttusers[0].topics == null) then
            null
        elif (.mqttusers[0].topics | type == "string") then
            .mqttusers[0].topics // empty
        elif (.mqttusers[0].topics | type == "boolean") then
            .mqttusers[0].topics // false
        elif (.mqttusers[0].topics | type == "array") then
            if (.mqttusers[0].topics == []) then
                empty
            else
                .mqttusers[0].topics[]
            end
        elif (.mqttusers[0].topics | type == "object") then
            if (.mqttusers[0].topics == {}) then
                empty
            else
                .mqttusers[0].topics
            end
        else
            .mqttusers[0].topics
        end

Proposed changes

fix the loop

addons-assistant[bot] commented 5 years ago

:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be usefull.

odtgit commented 5 years ago

with only one user defined it runs but not properly:

odt@cube ~> mosquitto_pub -d -t 'tellsticknet/ACCA540219F3/command/sensor/officewindow/state' -n -r
Client mosqpub|32496-cube sending CONNECT
Client mosqpub|32496-cube received CONNACK
Connection Refused: not authorised.
Error: The connection was refused.

This is the config with one user:

odt@cube /u/s/h/a/d/a0d7b954_mqtt> cat options.json
{
  "log_level": "debug",
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "web": {
    "enabled": true,
    "ssl": false
  },
  "broker": {
    "enabled": true,
    "enable_ws": false,
    "enable_mqtt": true,
    "enable_ws_ssl": false,
    "enable_mqtt_ssl": false,
    "allow_anonymous": false
  },
  "mqttusers": [
    {
      "username": "***",
      "password": "***",
      "readonly": false,
      "topics": [
        "#"
      ]
    }
  ]
}⏎            
Lastof commented 5 years ago

Probably a related issue on my end, I'm finding it does start, but takes an exponentially longer time depending on the number of users.

1 user: Started normally 2 users: Took maybe a minute 3 users: About 8 minutes 4 users: 45 minutes (21:46 - 22:29) 5 users: Almost 3 hours. I started it at 22:53, looks like it was up by 1:46am, though I'd gone to sleep.

The log gets as far as

[cont-init.d] 20-mqtt_broker.sh: executing... 
INFO: Adding configuration for MQTT Server...
INFO: Setting configuration for mqtt...

And just sits there for however long it takes.

ludeeus commented 5 years ago

A new version with fixes for all 3 problems will drop shortly.

ludeeus commented 5 years ago

Fixed in https://github.com/hassio-addons/addon-mqtt/releases/tag/v1.0.1

GitHub
hassio-addons/addon-mqtt
MQTT Server & Web client - Community Hass.io Add-on for Home Assistant - hassio-addons/addon-mqtt
addons-assistant[bot] commented 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.