As part of my work with MQTT I have developed a number of broker test tools that I use . They are written in python and Node-red and are probably only useful for small networks.
The are made available as-is and no warranty is accepted. You are free to modify them as you see fit but not to resell them.
Most of the tools are in early stages of development and I have been considering documented these tools and making them more user friendly, but before I do I would like to get your feedback as it involves considerable work on my part, and there is no point if the interest is very limited.
I would be grateful for you feedback by using the comments section.
This is a collection of python broker test scripts that you may find useful. The scripts are best run from an IDE as you will need to change settings for your environment.
All scripts have a use editable section near the top where you can make changes.
Maximum Connection Tester
Creates multiple connections to a broker both normal and SSL and then sends messages across them and measures the time taken.
I used this when testing the 1024 connection limit on Linux.
On windows there doesn’t appear to be a limit imposed by the OS but when run on Linux you may encounter this.
Details are in the install mosquitto on Linux tutorial
Broker Stress Tester
There is a transmitter script and receiver script. The receiver must be started before the transmitter.
The receiver and transmitter broker and port need editing. All other settings are in the transmitter script which sends X messages in Y blocks.Each message is Z bytes and there is a delay between each message which you can set as well as a longer delay between each block.
The message delay sets the message rate and you will find that decreasing it further than a set amount doesn’t make it any faster. The rate will depend on the machine you are using.
There is also the ability to inject an error as a means of sanity checking.
The default 10 blocks,200 messages per block with a message size of 1000 bytes and a 2 second delay between blocks.
broker="192.168.1.41" port=1883 blocks=10 #edit for number of blocks messages=200 #edit for messages per block message_size=1000 #edit for size of message M_delay=0.00001 #delay between messages Loop_delay=2 inject_error=False
You need to stop the receiver with CTRL+C as it will reset at the end of the test and wait for another test.
The receiver output is shown below:
Broker Up Checker
Checks a list of brokers to see if they are up and responsive. The tool attempts to connect to a list of brokers on a periodic basis.
It reports slow or down brokers on a topic that you can set. This can be used for notifications.
Currently logging to a file is not implemented.
You can increase the number of threads as he number of brokers that you are testing increases and the check period decreases.
A screen shot of the results is shown below: