shirou / mqttcli

MQTT client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config file handling broken

Luzifer opened this issue · comments

Commit ab28b9f introduced a bug with config file handling: When no host is specified the default is set to localhost and the configuration file is ignored:

$ mqttcli sub -d -t 'tele/outdoor/SENSOR'
INFO[0000] Broker URI: tcp://localhost:1883
INFO[0000] Topic: tele/outdoor/SENSOR
INFO[0000] connecting...

$ mqttcli sub --conf .mqttcli.conf -d -t 'tele/outdoor/SENSOR'
INFO[0000] Broker URI: tcp://localhost:1883
INFO[0000] Topic: tele/outdoor/SENSOR
INFO[0000] connecting...

$ mqttcli sub --host="" --conf .mqttcli.cfg -d -t 'tele/outdoor/SENSOR'
INFO[0000] Broker URI: tcp://<my configured server>:1883
INFO[0000] Topic: tele/outdoor/SENSOR
INFO[0000] connecting...

Only setting the host explicitly to "" ensures the configuration file is applied.

Ran into this same issue, addressed the symptom by adding this line to my .zshrc or .bashrc
export MQTT_HOST=""

Same end result, just avoids adding that empty string to every command

config reading order has been updated at 1e31202.