**MQTT Server-EMQ** ===  ## 使用 EMQ 原因 * 支援 Windows * 支援 cluster * 比較表的功能都有支援 * 更新很頻繁 ## 版本 * 2.3.9 (已下內容為此版本) ## API * Dashboard 已有介紹 http://127.0.0.1:18083/#/http_api * 文件中有介紹 http://emqtt.com/docs/v2/rest.html * Deme 專案以提供呼叫 api 的方法 ## EMQ Service ## Plugin (擴充功能) :::info * 各功能的設定檔路徑 emqttd\etc\plugins\ * Auth 名詞介紹 | 名詞 | 解釋 | | -------- | -------- | | Auth | 是否允許與 Server 的連線 | | Acl | 是否允許發佈 / 訂閱 | | SuperUser | 通過 Auth 後,接著會確認是否為 SuperUser。如果為 SuperUser,客戶端執行發佈與訂閱不會再經過 Acl 處理,直接為允許。 | ::: ### emq_modules (自動訂閱) * Enable Presence Module 是否起用傳送客戶端上/下訊息至 $SYS (系統主題) :::info config 設定範例: module.presence = on //是否起用 module.presence.qos = 1 //Qos ::: * Subscription Module 每個 Cilent 連接 Server 時自動訂閱 :::info 1. %c 為 ClientID 變數 2. %u 為 UserName 變數 config 設定範例: (每個用戶訂閱 test/{自己的 ClientID}/#) module.subscription.1.topic = test/%c/# //訂閱的主題 module.subscription.1.qos = 1 //Qos ::: * Rewrite Module 重寫主題 ### emq_web_hook (客戶端連線通知、訊息發佈通知) :::info config 設定範例 (以 EmqWebApiDemo 專案範例): web.hook.api.url = http://127.0.0.1:50111/api/EmqWebHook ::: | 通知內容 | 中譯 | | ----- | ---- | | client_connected | 客戶端連線 | | client_disconnected | 客戶端斷線 | | client_subscribe | 客戶端訂閱 | | client_unsubscribe | 客戶端取消訂閱 | |session_created|建立 Session| | session_subscribed | 建立 Session 訂閱主題 | | session_unsubscribed | 刪除 Session 訂閱主題 | |session_terminated|刪除 Session| | message_publish | 訊息發佈 | | message_delivered | 訊息送達 | | message_acked | 訊息發佈為 (Qos1/2) 才會有的 Ack | ### emq_auth_clientid (clientid Auth 認證) client 連線 Server 時需認證 clientid 和 password ::: warning 啟用認證相關 Plugin (擴充功能) ,需關閉 emq 匿名登入功能 <i class="fa fa-folder"></i> emqttd\etc\emq.conf mqtt.allow_anonymous = false ::: :::info config 設定允許的 client 範例 : auth.client.2.clientid = 123 (clientid) auth.client.2.password = 123 (password) ::: ### emq_auth_username (username Auth 認證) client 連線 Server 時需認證 clientid 和 password ::: warning 啟用認證相關 Plugin (擴充功能) ,需關閉 emq 匿名登入功能 <i class="fa fa-folder"></i> emqttd\etc\emq.conf mqtt.allow_anonymous = false ::: :::info config 設定允許的 username 範例 : auth.user.1.username = 123 (username) auth.user.1.password = 456 (password) ::: ### emq-auth-http (Auth、Acl、SuperUser) ::: info * 允許 : 回傳 HTTP Status Code 200 * 拒絕 : 回傳 HTTP Status Code 4xx ::: * Auth :::info config 設定範例 : * Api 網址 auth.http.auth_req = http://localhost:50111/api/EmqHttpAuth/Auth * Http Method auth.http.auth_req.method = post * 選擇要傳給 Api 的參數,%為變數 auth.http.auth_req.params = clientid=%c,username=%u,password=%P * 參數名稱是可以改的,如下為只傳送 test 參數,值為 clientid (%c)) auth.http.auth_req.params = test=%c * 可設定變數 1. %u: username (使用者名稱) 2. %c: clientid (客戶端 ID) 3. %a: ipaddress (客戶端 IP) 4. %P: password (使用者密碼) ::: * ACL :::info * 設定方式同 Auth,只列出可設定的變數 1. %u: username 2. %c: clientid 3. %a: ipaddress ::: * Superuser ::: info * 設定方式同 Auth,只列出可設定的變數 1. %A: 1 | 2, 1 = subscribe (訂閱), 2 = publish (發佈) 2. %u: username (使用者名稱) 3. %c: clientid (客戶端 ID) 4. %a: ipaddress (客戶端 IP) 5. %t: topic (主題) ::: ### 未實際做過的 Plugin * emq_auth_jwt (Auth) * emq_auth_ldap (Auth、Acl) * emq_auth_mongo (Auth、Acl) * emq_auth_mysql (Auth、Acl) * emq_auth_pgsql Auth、Acl) * emq_auth_redis (Auth、Acl) * emq_dashboard (wen 儀錶板) * emq_retainer (Retain (保留) 訊息,預設啟用) * emq_lua_hook (與 emq_web_hook 功能相同) * 啟用支援協定 * emq_sn * emq_stomp * emq_coap * 開發 Plugin 用 * emq_plugin_template * emq_reloader * emq_recon (應該是) .NET 開發 === * **Nuget** * Plt.M2Mqtt * M2MqttDotnetCore (NET Standard 2.0) :::danger 原版 M2Mqtt 作者已不更新 , 轉移到上面兩個繼續維護 ::: Tag === ###### tags: `Queue`,`MQTT`,`EMQ`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up