使用官网的docker-compose文件拉起的emq双节点
version: '3'
services:
emqx1:
image: emqx:5.5.0
container_name: emqx1
environment:
- "EMQX_NODE_NAME=emqx@node1.emqx.io"
- "EMQX_CLUSTER__DISCOVERY_STRATEGY=static"
- "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io,emqx@node2.emqx.io]"
healthcheck:
test: ["CMD", "/opt/emqx/bin/emqx ctl", "status"]
interval: 5s
timeout: 25s
retries: 5
networks:
emqx-bridge:
aliases:
- node1.emqx.io
ports:
- 1883:1883
- 8083:8083
- 8084:8084
- 8883:8883
- 18083:18083
# volumes:
# - $PWD/emqx1_data:/opt/emqx/data
emqx2:
image: emqx:5.5.0
container_name: emqx2
environment:
- "EMQX_NODE_NAME=emqx@node2.emqx.io"
- "EMQX_CLUSTER__DISCOVERY_STRATEGY=static"
- "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io,emqx@node2.emqx.io]"
healthcheck:
test: ["CMD", "/opt/emqx/bin/emqx ctl", "status"]
interval: 5s
timeout: 25s
retries: 5
networks:
emqx-bridge:
aliases:
- node2.emqx.io
# volumes:
# - $PWD/emqx2_data:/opt/emqx/data
networks:
emqx-bridge:
driver: bridge
Dashboard中确认开启了共享订阅,后使用MQTTX客户端测试如下:
-
建立两个连接,创建共享订阅: $share/xx/t/#
-
创建第三个连接向主题: /t/1 发送消息,共享订阅没有生效,没收到任何消息
-
客户端连接切换到 broker.emqx.io 重试也无法收到共享消息