You need to enable JavaScript to run this app.
导航
MQTTx CLI测试 EMQx
最近更新时间:2025.03.05 21:44:45首次发布时间:2025.03.05 21:44:45

MQTTx

MQTTX CLIEMQ 开源的一款 MQTT 5.0 命令行客户端工具,也是命令行上的 MQTTX,旨在帮助模拟mqtt客户端。 https://mqttx.app/zh

安装 CLI

  • 参考 mqttx 官方文档 https://mqttx.app/zh/docs/cli/downloading-and-installation
  • 以 MacOS 为例
brew install emqx/mqttx/mqttx-cli
curl -LO https://www.emqx.com/zh/downloads/MQTTX/${version}/mqttx-cli-linux-x64
sudo install ./mqttx-cli-linux-x64 /usr/local/bin/mqttx

创建 VPC - TCP 接入点

配置 EMQx Web控制台用户

  • 请在EMQx web控制台中配置 mqtt client 的用户名和密码用于认证
  • 参考 登录 Dashboard

MQTT Web控制台中配置用户 和 授权

  • 在 Web 控制台中配置 mqtt client 的用户名和密码

Image

  • 并为其配置客户端授权
    • 例子中配置为所有用户
    • mqtt topic 匹配 devices/#

Image

MQTT 协议测试

  • 替换下方参数
    • -h 替换为 mqtt 的 vpc 接入地址 或者 公网接入地址
    • -u 替换为 emqx 的 username
    • -P 替换为 emqx 的 password
    • --count 替换为需要构造的客户端数量
mqttx bench pub \
  -h '${mqtt-broker-endpoint}' \
  -p 1883 \
  -c 1000 \
  -u '${username}' \
  -P '${password}' \
  -t 'devices/data' \
  -m '{"temperature": 25, "humidity": 65}' \
  --count ${client_number} \
  --interval 100

MQTTS 协议测试

  • 替换下方参数
    • -h 替换为 mqtt 的 vpc 接入地址 或者 公网接入地址
    • -u 替换为 emqx 的 username
    • -P 替换为 emqx 的 password
    • --count 替换为需要构造的客户端数量
mqttx bench pub \
  -h '${mqtt-broker-endpoint}' \
  -p 8883 \
  -c 1000 \
  -u '${username}' \
  -P '${password}' \
  -t 'devices/data' \
  -m '{"temperature": 25, "humidity": 65}' \
  --count ${client_number} \
  --interval 100
  --protocol mqtts