shirou / mqttcli

MQTT client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Host parameter ignored

Magnum5234 opened this issue · comments

Hey, thx for this tool :)

The host parameter is completely ignored.

% mqttcli pub -h 10.10.5.20 -t 'test' -m 'test message' -d
INFO[0000] Broker URI: tcp://localhost:1883             
INFO[0000] connecting...                                
INFO[0000] Topic: test                                  
INFO[0000] client connected                             
INFO[0000] Published                                    
INFO[0000] client disconnected                          

If fixed this by changing
https://github.com/shirou/mqttcli/blob/master/mqtt.go#L123

to

host := c.String("h")
commented

h is an alias where defined here. So both h and host should work. Other alias parameters such as p and port are also works even if only p is used in the code. (Yes, I found inconsistency. but it works.)

My thanks as well, this is exactly what I was looking for!

The -h/--host parameter isn't working for me either....the config file works fine:

./mqttcli_linux_amd64 pub -d -h "192.168.101.25" -p "1883" -t "test/kg" -m "1"
INFO[0000] Broker URI: tcp://localhost:1883             
INFO[0000] connecting...                                
ERRO[0000] network Error : dial tcp 127.0.0.1:1883: connect: connection refused 

./mqttcli_linux_amd64 pub -d --host "192.168.101.25" -p "1883" -t "test/kg" -m "1"
Incorrect Usage: flag provided but not defined: -host

I noticed 0.1.0 release binaries do not include this host alias flag. I have released 0.2.0. Please try to use that version.

Yep, works for me....thanks!