一、mosquitto搭建
1.1 mosquitto介紹
Eclipse Mosquitto是一個(gè)開(kāi)源(EPL/EDL許可)消息代理(broker),它實(shí)現(xiàn)了MQTT協(xié)議版本5.0、3.1.1和3.1。Mosquito重量輕,適用于從低功耗單板計(jì)算機(jī)到完整服務(wù)器的所有設(shè)備。
1.2 使用mosquitto在windows下創(chuàng)建一個(gè)mqtt broker
step1)使能mosquitto服務(wù)
step2)配置mosquitto
MQTT協(xié)議端口號(hào)
listener 1883
啟用WebSocket支持
listener 9001
protocol websockets
訂閱主題持久化
persistence true
persistence_location D:softwaremosquittodata
開(kāi)啟日志記錄
log_dest file D:softwaremosquittomosquitto.log
log_type all
開(kāi)啟密碼驗(yàn)證
password_file D:softwaremosquittopwfile.example
allow_anonymous false
step3)創(chuàng)建訪(fǎng)問(wèn)mqtt broker的賬戶(hù)
mosquitto_passwd.exe用于生成連接mqtt broker的用戶(hù)名和密碼,下面的命令表示向pwfile.example文件追加一個(gè)“myAccount”賬戶(hù),在client中可以用這個(gè)賬戶(hù)和密碼登錄,否則會(huì)報(bào)驗(yàn)證失敗的錯(cuò)誤。
.mosquitto_passwd.exe .pwfile.example myAccount
step4)啟動(dòng)mqtt broker
執(zhí)行下面的命令可以啟動(dòng)一個(gè)mqtt服務(wù)器
.mosquitto.exe -v -c .configmosquitto.conf
二、mqtt網(wǎng)絡(luò)包分析
-
RT-Thread
+關(guān)注
關(guān)注
32文章
1406瀏覽量
41920 -
MQTT協(xié)議
+關(guān)注
關(guān)注
0文章
99瀏覽量
5939
發(fā)布評(píng)論請(qǐng)先 登錄
評(píng)論