用于在多个主题上生成MQTT消息的工具
项目描述
在测试处理MQTT消息的应用程序和工具时,通常需要在随机主题上持续向代理发送消息。《mqtt-randompub》包含发送单个消息、指定数量的消息或直到工具终止的恒定流消息的选项。配置文件可用于存储主题列表以创建可重复的测试场景。
先决条件/安装
获取文件
克隆mqtt-randompub 仓库
git clone git@github.com:fabaff/mqtt-randompub.git
或使用pip进行安装。
pip3 install mqtt-randompub --user
依赖关系
mqtt-randompub 仅依赖于 paho-mqtt。此模块应在使用pip安装时自动引入。
Fedora系统
sudo dnf -y install python-paho-mqtt
用法
要在终端中运行mqtt-randompub,只需键入
$ mqtt-randompub -h usage: mqtt-randompub [-h] [-c CONFIG] [-b BROKER] [-p PORT] [-q QOS] [-t TOPIC] [-s SUBTOPIC1] [-d SUBTOPIC2] [-l LOAD] [-i INTERVAL] [-n NUMBER] optional arguments: -h, --help show this help message and exit -c CONFIG, --config CONFIG configuration file to use -b BROKER, --broker BROKER set the broker -p PORT, --port PORT set the proker port -q QOS, --qos QOS set the QoS of the messages -t TOPIC, --topic TOPIC set the main topic -s SUBTOPIC1, --subtopic1 SUBTOPIC1 set the first subtopic -d SUBTOPIC2, --subtopic2 SUBTOPIC2 set the second subtopic -l LOAD, --load LOAD what to use as message payload -i INTERVAL, --interval INTERVAL time in seconds between the messages -n NUMBER, --number NUMBER number of messages to send. set to 0 for running
以查看所有选项。在没有选项的情况下运行将向监听在本地主机上的端口1883的代理发送示例消息到test/#。
对于本地测试,请在 localhost 上运行一个 MQTT 代理/服务器。
然后使用 MQTT 客户端订阅 test/# 主题。例如
mosquitto_sub -h localhost -d -t test/#
您可以使用配置文件运行 mqtt-randompub 以重用之前设置的主题。有关详细信息,请参阅 mqtt-randompub.example 文件。
许可证
mqtt-randompub 使用 MIT 许可,有关更多信息请查看 LICENSE。
项目详情
下载文件
下载适合您平台的应用文件。如果您不确定该选择哪个,请了解更多关于 安装包 的信息。
源代码分发
mqtt-randompub-0.2.2.tar.gz (6.1 kB 查看哈希值)
构建分发
关闭
mqtt-randompub-0.2.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 24a3e4c3ecaeaab72949ad60077ba59a824147763c0789b74df04bf9fe1e8d1f |
|
MD5 | df2e163d233c4663ca42cb03b90a4f30 |
|
BLAKE2b-256 | 26ac1cccd285d507dced7e01e8836a6997c84a8d5f5b0dd26fa64396fa1cca49 |
关闭
mqtt_randompub-0.2.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4d1625c1f272bd24e701ac786bf8e9cdb3962aa68cf381aa216c280137661522 |
|
MD5 | a1545e54177823df414df9488bd27ca9 |
|
BLAKE2b-256 | bf0ac11a502d6d0a1b0c8e68538cc5f9825831c151c2e88e668ae86c8b6babe6 |