使用mqtt测试服务器测试mqtt通信
mqtt 订阅命令
mosquitto_sub -L mqtt://test.mosquitto.org:1883/const.net.cn/
mosquitto_sub -L参数说明
-L : specify user, password, hostname, port and topic as a URL in the form:
mqtt(s)://[username[:password]@]host[:port]/topic
mqtt 发布命令
mosquitto_pub -L mqtt://test.mosquitto.org/const.net.cn/ -m 'mqtt hello world test.mosquitto.org 1883 : MQTT, unencrypted, unauthenticated'
带调试数据的 mqtt 发布命令
mosquitto_pub -L mqtt://test.mosquitto.org/const.net.cn/ -m 'mqtt hello world test.mosquitto.org 1883 : MQTT, unencrypted, unauthenticated' -d
Client mosq-m1kd4t2Yz2Hext8Zot sending CONNECT
Client mosq-m1kd4t2Yz2Hext8Zot received CONNACK (0)
Client mosq-m1kd4t2Yz2Hext8Zot sending PUBLISH (d0, q0, r0, m1, 'const.net.cn/', ... (77 bytes))
Client mosq-m1kd4t2Yz2Hext8Zot sending DISCONNECT
接收到的数据:
mosquitto_sub -L mqtt://test.mosquitto.org:1883/const.net.cn/ -v
const.net.cn/ mqtt hello world test.mosquitto.org 1883 : MQTT, unencrypted, unauthenticated
const.net.cn/ mqtt hello world test.mosquitto.org 1883 : MQTT, unencrypted, unauthenticated
本文链接地址:https://const.net.cn/147.html