系統版本: ubuntu 16.04 LTS
EMQ 版本: 2.3.11
我使用的代理就是 EMQ(emqttd) 介紹或者詳細的配置能夠到官網看看. 我這裏只寫一些主要的配置.html
我從官網下載的是 emqttd-ubuntu16.04-v2.3.11_amd64.deb
下載後直接雙擊安裝便可.node
安裝後在控制檯輸出 sudo emqttd console
來啓動代理. 啓動後會輸出以下信息.shell
Exec: /usr/lib/emqttd/erts-9.0/bin/erlexec -boot /usr/lib/emqttd/releases/2.3.11/emqttd -mode embedded -boot_var ERTS_LIB_DIR /usr/lib/emqttd/erts-9.0/../lib -mnesia dir "/var/lib/emqttd/mnesia/emq@127.0.0.1" -config /var/lib/emqttd/configs/app.2018.10.03.18.37.02.config -args_file /var/lib/emqttd/configs/vm.2018.10.03.18.37.02.args -vm_args /var/lib/emqttd/configs/vm.2018.10.03.18.37.02.args -- console Root: /usr/lib/emqttd /usr/lib/emqttd Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:32] [hipe] [kernel-poll:true] starting emqttd on node 'emq@127.0.0.1' emqttd ctl is starting...[ok] emqttd hook is starting...[ok] emqttd router is starting...[ok] emqttd pubsub is starting...[ok] emqttd stats is starting...[ok] emqttd metrics is starting...[ok] emqttd pooler is starting...[ok] emqttd trace is starting...[ok] emqttd client manager is starting...[ok] emqttd session manager is starting...[ok] emqttd session supervisor is starting...[ok] emqttd wsclient supervisor is starting...[ok] emqttd broker is starting...[ok] emqttd alarm is starting...[ok] emqttd mod supervisor is starting...[ok] emqttd bridge supervisor is starting...[ok] emqttd access control is starting...[ok] emqttd system monitor is starting...[ok] emqttd 2.3.11 is running now Eshell V9.0 (abort with ^G) (emq@127.0.0.1)1> Load emq_mod_presence module successfully. dashboard:http listen on 0.0.0.0:18083 with 4 acceptors. mqtt:tcp listen on 127.0.0.1:11883 with 4 acceptors. mqtt:tcp listen on 0.0.0.0:1883 with 16 acceptors. mqtt:ws listen on 0.0.0.0:8083 with 4 acceptors. mqtt:ssl listen on 0.0.0.0:8883 with 16 acceptors. mqtt:wss listen on 0.0.0.0:8084 with 4 acceptors. mqtt:api listen on 0.0.0.0:8080 with 4 acceptors.
也能夠用這兩個命令來啓停
systemctl start emqttd
systemctl stop emqttd
目錄 | 說明 |
---|---|
/usr/lib/emqttd/ | 全部的可執行文件包括插件 |
/etc/emqttd/ | 保存全部配置文件包括插件配置 |
屬性名 | 說明 |
---|---|
node.process_limit | Erlang 虛擬機容許的最大進程數,一個 MQTT 鏈接會消耗2個 Erlang 進程,因此參數值 > 最大鏈接數 * 2 |
node.max_ports | Erlang 虛擬機容許的最大 Port 數量,一個 MQTT 鏈接消耗1個 Port,因此參數值 > 最大鏈接數 |
node.dist_listen_min | Erlang 分佈節點間通訊使用 TCP 鏈接端口範圍。注: 節點間若有防火牆,須要配置該端口段 |
node.dist_listen_max | Erlang 分佈節點間通訊使用 TCP 鏈接端口範圍。注: 節點間若有防火牆,須要配置該端口段 |
## Console log. Enum: off, file, console, both log.console = console ## Console log level. Enum: debug, info, notice, warning, error, critical, alert, emergency log.console.level = error ## Console log file ## log.console.file = log/console.log
## Error log file log.error.file = log/error.log
## Enable the crash log. Enum: on, off log.crash = on log.crash.file = log/crash.log
## Syslog. Enum: on, off log.syslog = on ## syslog level. Enum: debug, info, notice, warning, error, critical, alert, emergency log.syslog.level = error
## Max ClientId Length Allowed. mqtt.max_clientid_len = 1024
## Max Packet Size Allowed, 64K by default. mqtt.max_packet_size = 64KB
設置 MQTT 客戶端最大容許閒置時間(Socket 鏈接創建, 但未收到 CONNECT 報文):ubuntu
## Client Idle Timeout (Second) mqtt.client.idle_timeout = 30
## Enable client Stats: on | off mqtt.client.enable_stats = off
## Force GC: integer. Value 0 disabled the Force GC. mqtt.conn.force_gc_count = 100
關於插件的配置參考這裏api
EMQ 消息服務器認證由一系列認證插件(Plugin)提供,系統支持按用戶名密碼、ClientID 或匿名認證.服務器
系統默認開啓匿名認證(anonymous),經過加載認證插件可開啓的多個認證模塊組成認證鏈:session
---------------- ---------------- ------------ Client --> | Username認證 | -ignore-> | ClientID認證 | -ignore-> | 匿名認證 | ---------------- ---------------- ------------ | | | \|/ \|/ \|/ allow | deny allow | deny allow | deny
若是開啓 用戶名和密碼 認證以及 客戶ID認證時, 咱們會先判斷 用戶名和密碼 若是認證成功會忽略客戶端ID, 若是認證失敗則會去認證客戶端ID.app
⚠️ 客戶端ID也須要配置密碼. 用戶名和密碼以及客戶端ID都是惟一的, 並且鏈接到代理的會話也是惟一的. 二次鏈接代理會將前一個下線.