mosquitto_sub和pub需要主机地址或ip。例如,我在我的本地使用test.mosquitto.org,从该站点下载pem格式的证书文件,并将此证书添加到conf文件中作为“cafile”。这是我的命令:
mosquitto_sub -h test.mosquitto.org -t "test" -p 8883 --cafile "<pem formatted crt file path (downloaded from test.mosquitto.org)>"