emqx

EMQX MQTT 消息服务器

补充说明

EMQX 是面向 IoT 的高性能 MQTT Broker,支持 MQTT 3.1/3.1.1/5.0、WebSocket、共享订阅、规则引擎和集群。默认 MQTT 端口 1883,TLS 8883,Dashboard 18083。生产环境关注认证、ACL、会话持久化和集群发现。

常用示例

启动单节点:

docker run -d --name emqx \
  -p 1883:1883 -p 8083:8083 -p 8883:8883 \
  -p 18083:18083 \
  emqx/emqx:5.8

查看节点和监听器:

emqx ctl status
emqx ctl listeners
emqx ctl broker stats

发布和订阅:

mosquitto_sub -h 127.0.0.1 -p 1883 -t 'sensors/#' -v
mosquitto_pub -h 127.0.0.1 -p 1883 -t 'sensors/room1/temp' -m '23.5' -q 1

创建 Dashboard 管理员:

emqx ctl admins add admin '***'

内置认证用户和规则引擎通过 Dashboard 或 HTTP API 管理,CLI 只提供查看能力:

emqx ctl rules list
emqx ctl rules show <RuleID>

查看集群:

emqx ctl cluster status
emqx ctl cluster join emqx@node2

易错点与排错