MQTT Explorer 工具
MQTT Explorer 工具
Section titled “MQTT Explorer 工具”本节介绍 MQTT Explorer——一款功能强大的 MQTT 可视化调试工具。学习完成后,您将能够:
- 安装和配置 MQTT Explorer
- 使用 MQTT Explorer 浏览和监控 MQTT 通信
- 利用 MQTT Explorer 进行系统调试
- 在售前演示中展示 MQTT Explorer
在开始本节之前,请确保:
- MQTT Broker 已运行
- 系统中有活动的 MQTT 通信
- 了解 MQTT 基本概念
什么是 MQTT Explorer?
Section titled “什么是 MQTT Explorer?”MQTT Explorer 是由 Thomas Nordquist 开发的开源 MQTT 可视化工具,支持 Windows、macOS 和 Linux。
核心功能:
- 实时浏览 MQTT Topic 结构(树形展示)
- 查看和发布消息
- 监控 Topic 变化
- 支持保留消息和通配符
- 历史消息回放
适用场景:
- 开发和调试 MQTT 应用
- 售前演示 IoT 系统
- 系统运行时监控
- 教学和培训
Installation
Section titled “Installation”Download and Install
Section titled “Download and Install”支持的平台:├── Windows: 下载 .exe 安装包├── macOS: 下载 .dmg 文件└── Linux: 下载 AppImage 或通过 snap 安装
下载地址:https://mqtt-explorer.com/macOS 安装:
# 方式 1: 直接下载 .dmg 安装# 方式 2: 通过 Homebrewbrew install --cask mqtt-explorerLinux 安装:
# 下载 AppImagewget https://github.com/thomasnordquist/MQTT-Explorer/releases/latest/download/MQTT-Explorer.AppImagechmod +x MQTT-Explorer.AppImage./MQTT-Explorer.AppImageConfiguration
Section titled “Configuration”Connection Setup
Section titled “Connection Setup”连接配置界面:
Connection Name: Factory Demo (自定义名称)Protocol: mqtt://Hostname: localhost (或 Broker IP)Port: 1883SSL/TLS: 关闭 (开发环境)
Authentication: Username: (可选) Password: (可选)
Advanced: Client ID: mqtt_explorer_demo (自动生成) Keep Alive: 60 Clean Session: true
点击 "CONNECT" 按钮Connection Templates
Section titled “Connection Templates”常用连接配置模板:
1. 本地开发环境 Host: localhost Port: 1883
2. 远程服务器(无加密) Host: 192.168.1.100 Port: 1883
3. 远程服务器(TLS 加密) Host: iot.factory.com Port: 8883 SSL/TLS: 启用
4. Docker 内部 Host: mosquitto (容器名) Port: 1883Main Interface
Section titled “Main Interface”UI Overview
Section titled “UI Overview”MQTT Explorer 主界面布局:
┌─────────────────────────────────────────────────────────┐│ 工具栏: 连接/断开 | 发布消息 | 历史记录 | 设置 │├────────────┬────────────────────────────────────────────┤│ 连接管理 │ 消息浏览区 ││ │ ││ Connections│ Topic 树形结构: ││ ├─ Factory │ └─ factory ││ │ Demo │ ├─ zone1 ││ │ │ │ ├─ temperature ← 26.5°C ││ │ │ │ ├─ humidity ← 62% ││ │ │ │ └─ light ← 450 lux ││ │ │ └─ zone2 ││ │ │ ├─ temperature ← 28.0°C ││ │ │ └─ humidity ← 55% ││ │ │ ││ │ │ 底部: 消息详情区 ││ │ │ 显示选中 Topic 的详细信息 │├────────────┴────────────────────────────────────────────┤│ 状态栏: 连接状态 | 消息数 | 订阅数 │└─────────────────────────────────────────────────────────┘Key Features
Section titled “Key Features”1. Topic 树形浏览: 所有 Topic 自动按层级结构以树形展示,一眼看清系统架构
2. 实时更新: 消息到达时 Topic 节点自动高亮,显示最新值
3. 消息历史: 每个 Topic 保存历史消息,可回溯查看
4. 发布消息: 直接双击 Topic 或点击发布按钮发送消息
5. 搜索过滤: 支持按 Topic 名称搜索和过滤
Practical Usage
Section titled “Practical Usage”Debugging with MQTT Explorer
Section titled “Debugging with MQTT Explorer”调试案例:排查传感器数据问题
1. 连接到 Broker2. 展开 Topic 树查看结构3. 检查 sensors/environment Topic: - 数据显示了吗? - 数据更新频率正常吗? - 数据格式正确吗(JSON 自动格式化和高亮)?
4. 如果数据异常: - 发布测试消息到相同的 Topic - 验证 Node-RED 是否正确接收 - 检查数据格式是否符合预期Publishing Messages
Section titled “Publishing Messages”发布消息步骤:1. 双击任意 Topic 节点2. 在弹出的发布窗口输入: - Topic: (自动填充) - Payload: {"temperature": 28.5, "humidity": 65} - QoS: 1 - Retain: ✓3. 点击 "PUBLISH" 按钮Scenario: 售前演示
Section titled “Scenario: 售前演示”在售前演示中使用 MQTT Explorer:
1. 展示 Topic 结构 - 展示 IoT 系统的 Topic 组织方式 - 解释数据分类和层级关系
2. 实时数据展示 - 演示传感器数据实时更新 - 展示 JSON 数据的结构化视图
3. 发送控制命令 - 直接通过界面发布控制命令 - 展示设备的实时响应
4. 展示系统概览 - 一眼看到所有设备和数据 - 证明系统架构的清晰性Advanced Features
Section titled “Advanced Features”Topic Filtering
Section titled “Topic Filtering”使用 Topic 过滤器只显示关心的内容:
过滤器语法:- factory/# → 只显示 factory 下的所有 Topic- +/temperature → 显示所有温度数据- devices/+/status → 显示所有设备状态
应用过滤后,树形结构只显示匹配的 TopicMessage History
Section titled “Message History”每个 Topic 都保存了消息历史记录:
功能:- 查看 Topic 的历史消息序列- 分析数据变化趋势- 回溯问题发生时间
时间范围:- 默认保存最后 100 条消息- 可在设置中调整Export and Import
Section titled “Export and Import”配置导出:- 导出连接配置(便于分享)- 导出 Topic 树结构快照
数据导出:- 导出 Topic 历史数据为 CSV 或 JSON- 用于进一步分析或报告Search
Section titled “Search”快速搜索 Topic:
搜索功能:- 按 Topic 名称搜索- 按消息内容搜索- 支持正则表达式
应用场景:- 在大量 Topic 中快速定位特定传感器- 查找包含特定关键词的消息Tips and Tricks
Section titled “Tips and Tricks”Keyboard Shortcuts
Section titled “Keyboard Shortcuts”常用快捷键:Ctrl+N → 新建连接Ctrl+E → 发布消息Ctrl+F → 搜索Ctrl+R → 刷新Ctrl+W → 关闭当前连接F5 → 刷新 Topic 树Configuration File Location
Section titled “Configuration File Location”配置文件存储位置:
Windows: %APPDATA%/MQTT Explorer/macOS: ~/Library/Application Support/MQTT Explorer/Linux: ~/.config/MQTT Explorer/
用途:- 备份连接配置- 跨设备同步设置- 恢复丢失的配置Comparison: CLI vs GUI
Section titled “Comparison: CLI vs GUI”| 特性 | mosquitto_sub (CLI) | MQTT Explorer (GUI) |
|---|---|---|
| 安装大小 | < 1MB | ~50MB |
| 启动速度 | 即时 | ~3 秒 |
| Topic 浏览 | 逐行文本 | 树形可视化 |
| 消息发布 | 命令行输入 | 图形界面 |
| 数据格式化 | 原始 JSON | 格式化高亮 |
| 历史记录 | 无 | 有 |
| 远程连接 | SSH 依赖 | 直接支持 |
| 批量测试 | 脚本支持 | 有限 |
| 适合场景 | 自动化/脚本 | 开发/调试/演示 |
Summary
Section titled “Summary”本节要点总结:
- MQTT Explorer:功能强大的 MQTT 可视化调试工具
- 核心功能:Topic 树形浏览、实时监控、消息发布、历史记录
- 使用场景:开发调试、售前演示、系统监控
- 优势:直观的图形界面、自动 JSON 格式化、Topic 结构一目了然
- 跨平台:支持 Windows、macOS、Linux