一些MQTT代理接受身份验证令牌作为用户名(例如 mqtt.flespi.io(。在man mosquitto_pub
中,我发现客户端支持配置文件:
文件
$XDG_CONFIG_HOME/mosquitto_sub, $HOME/.config/mosquitto_pub 默认选项的配置文件。
但是没有关于文件格式的说明。我试过这个:
username=foobar..token
# and
username foobar..token
# and
--username=foobar..token
# and
foobar..token@host.name:port
# and some other
# that I found in https://github.com/eclipse/mosquitto/blob/master/client/client_shared.c
但在所有情况下,我只有
Error: Unknown option '--username.. and so on'.
而且我不太擅长C-lang。有人可以告诉我如何正确烹饪吗?
啊哈,似乎我找到了它(在最后一个可能的组合中我没有测试(:
# ~/.config/mosquitto_pub
--username <username-or-token>
-h <broker.addre.ss>
# and so on
因此,正确的格式是带有铅破折号并且没有等号
现在它允许使用短参数列表执行mosquitto_pub
:
mosquitto_pub -t mydata/update -m 4