1. 程式人生 > >物聯網MQTT協議

物聯網MQTT協議

記錄:阿里雲伺服器上使用mosquitto去實現MQTT功能,為什麼選擇這個呢?他是用C、C++實現的,有利於嵌入式端的互動。其次在https://github.com/mqtt/mqtt.github.io/wiki/servers?spm=5176.100239.blogcont41705.3.prfmir
裡他排在ibm官方提供方案的第一個位置。
關於服務的啟動與關閉命令:
關閉命令:
/etc/init.d/mosquitto stop
啟動命令:
mosquitto -c /etc/mosquitto/myconfig/mosquitto.config
訂閱主題:
mosquitto_sub -v -t sensor
釋出訊息:
mosquitto_pub -t sensor -m 12
檢視Mqtt服務端的執行狀況
mosquitto_sub -v -t $

SYS/#
SYSSYS/broker/bytes/received
自伺服器啟動以來共接收的位元組數
SYS/broker/bytes/sentSYS/broker/clients/connected,
SYS/broker/clients/active(1.4)SYS/broker/clients/expired
超過有效期被斷開連線的客戶端數量,有效期通過persistent_client_expiration引數設定。
SYS/broker/clients/disconnected,SYS/broker/clients/inactive (1.4版本已取消)
註冊到伺服器上的持久連線(clean seesion為假)但當前斷開的客戶端數量
S
YS/broker/clients/maximum
SYS/broker/clients/total
有效和無效連線、註冊到伺服器上的總數。
SYS/broker/connection/#  
如果伺服器設定了橋接,系統會提供一個主題來標識連線狀態,預設使用
SYS/broker/connection/,如果主題值為1表示連線啟用,如果為0表示連線沒有啟用。
SYS/broker/heap/currentsizeMosquitto使使SYS/broker/heap/maximum size
Mosquitto使用的最大堆記憶體。這個引數是否有效也取決於系統編譯時的相關引數設定。
S
YS/broker/load/connections/+connections+min,5min,15min
15