使用mqtt测试服务器测试mqtt 1884 通信
mqtt 1884 通信采用不加密,但需要验证的方法,登录用户名与密码的参数为-u和-P.
不使用密码登录:
mosquitto_sub -L mqtt://test.mosquitto.org:1884/const.net.cn/ -v
Connection error: Connection Refused: not authorised.
使用密码登录:
mosquitto_sub -L mqtt://test.mosquitto.org:1884/const.net.cn/ -v -u rw -P readwrite
不使用密码时:
mosquitto_pub -L mqtt://test.mosquitto.org:1884/const.net.cn/ -m 'mqtt hello world test.mosquitto.org 1884 : MQTT, unencrypted, authenticated' -d
Client mosq-dZTvqWrOBAwBY0e81Q sending CONNECT
Client mosq-dZTvqWrOBAwBY0e81Q received CONNACK (5)
Connection error: Connection Refused: not authorised.
Client mosq-dZTvqWrOBAwBY0e81Q sending DISCONNECT
使用用户名密码登录:
mosquitto_pub -L mqtt://test.mosquitto.org:1884/const.net.cn/ -m 'mqtt hello world test.mosquitto.org 1884 : MQTT, unencrypted, authenticated' -d -u rw -P readwrite
Client mosq-euDtfmG2k4QCjlSt9g sending CONNECT
Client mosq-euDtfmG2k4QCjlSt9g received CONNACK (0)
Client mosq-euDtfmG2k4QCjlSt9g sending PUBLISH (d0, q0, r0, m1, 'const.net.cn/', ... (75 bytes))
Client mosq-euDtfmG2k4QCjlSt9g sending DISCONNECT
接收到的消息:
mosquitto_sub -L mqtt://test.mosquitto.org:1884/const.net.cn/ -v -u rw -P readwrite
const.net.cn/ mqtt hello world test.mosquitto.org 1884 : MQTT, unencrypted, authenticated
const.net.cn/ mqtt hello world test.mosquitto.org 1884 : MQTT, unencrypted, authenticated
本文链接地址:https://const.net.cn/148.html