這篇文章的知識(shí)點(diǎn)包括:mosquitto的安裝下載、mosquitto的配置以及mosquitto的使用,閱讀完整文相信大家對(duì)MQTT服務(wù)器中mosquitto的有了一定的認(rèn)識(shí)。
黑龍江網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)建站!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)建站從2013年成立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)建站。
Mosquitto有很多版本,如果想體驗(yàn)新版本可以上github下載源文件編譯,比較麻煩。我這里使用Mosquiitto提供的windows版本,雖然版本不是最新的,但是穩(wěn)定。
從官網(wǎng)下載https://mosquitto.org/download/, 目前最新版本為
mosquitto-1.6.8-install-windows-x64.exe
雖然一路“下一步”很爽,為了默認(rèn)的路徑“C:\Program Files\mosquitto”包含了空格,所以這里安裝時(shí)在C盤的mosquitto目錄下。
如下圖所示,點(diǎn)擊啟動(dòng)服務(wù)后,mosquitto命令才可用。
進(jìn)入“C:\mosquitto”目錄下,可以查看mosquitto的配置文件及命令
找到mosquitto.conf文件,在任意位置添加如下代碼,重啟服務(wù)生效。
# 設(shè)置不允許匿名登錄
allow_anonymous false
# 設(shè)置賬戶密碼文件位置為C:\mosquitto\pwfile.example
password_file /mosquitto/pwfile.example
mosquitto_passwd -c pwfile.example username (使用-c 參數(shù)會(huì)導(dǎo)致清空密碼文件,重新插入用戶)
mosquitto_passwd pwfile.example username(不使用-c 表示追加用戶,不影響舊用戶)
C:\mosquitto>mosquitto_passwd.exe pwfile.example username
Password:
Reenter password:
添加成功后pwfile.example會(huì)出現(xiàn)剛剛添加的用戶信息。
新開一命令行窗口,使用以下命令啟動(dòng)服務(wù)。
C:\mosquitto>mosquitto.exe -c mosquitto.conf
新開一命令行窗口,訂閱消息 mosquitto_sub -u cx -P cx -t 'virus /topic' -v, 當(dāng)執(zhí)行5.3命令時(shí),該窗口會(huì)接收到訂閱消息。
C:\mosquitto>mosquitto_sub -u cx -P cx -t 'virus /topic' -v
'virus/topic' '消滅病毒'
'virus/topic' '消滅病毒'
'virus /topic' '消滅病毒'
新開一命令行窗口,發(fā)送消息 mosquitto_pub -u cx -P cx -t 'virus/topic' -m '消滅病毒'
C:\mosquitto>mosquitto_pub -u cx -P cx -t 'virus/topic' -m '消滅病毒'
看完上述內(nèi)容,你們對(duì)MQTT服務(wù)器中mosquitto有進(jìn)一步的了解嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
本文標(biāo)題:windows怎么安裝MQTT服務(wù)器?
網(wǎng)頁(yè)鏈接:http://jinyejixie.com/article0/ppshoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、軟件開發(fā)、用戶體驗(yàn)、面包屑導(dǎo)航、網(wǎng)站設(shè)計(jì)公司、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)