使用mqtt测试服务器测试mqtts 8885 tls单向认证带用户名密码加密通信
8885 : MQTT, encrypted, authenticated
需要用户名,密码,和ca证书。
订阅命令:
mosquitto_sub -L "mqtts://test.mosquitto.org:8885/const.net.cn" --cafile ../mosquitto.org.crt -u rw -P readwrite -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: const.net.cn, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 0
带Qos的订阅命令:
mosquitto_sub -L "mqtts://test.mosquitto.org:8885/const.net.cn/" --cafile ../mosquitto.org.crt -u rw -P readwrite -q 2 -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: const.net.cn/, QoS: 2, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 2
发布命令:
mosquitto_pub -L "mqtts://test.mosquitto.org:8885/const.net.cn/" --cafile ../mosquitto.org.crt -u rw -P readwrite -m 'mqtt example 8885 : MQTT, encrypted, authenticated' -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending PUBLISH (d0, q0, r0, m1, 'const.net.cn/', ... (50 bytes))
Client (null) sending DISCONNECT
接收到的数据
Client (null) received PUBLISH (d0, q0, r0, m0, 'const.net.cn/', ... (50 bytes))
mqtt example 8885 : MQTT, encrypted, authenticated
测试过程中,出现了一点问题,已经设置了Qos为2,却怎么也收不到mqtt信息,最后发现topic少了一个斜杠,发送为const.net.cn/,接收/订阅为const.net.cn,怎么也收不到信息。。怀疑人生。。。。
本文链接地址:https://const.net.cn/152.html