R&D Corner
-
Here is a basic example of a Python script that can be used to perform a stress test on a Mosquitto MQTT client :
This script creates an MQTT client, connects it to the specified broker, and then sends 100,000 messages to the specified topic. The delay between each message is set to 0.001 seconds to simulate a high rate of messages being sent. You can modify this script to increase or decrease the number of messages, change the delay between messages, or customize the topic and other settings as needed.
import paho.mqtt.client as mqtt
import time
broker = ‘localhost’
topic = ‘test’
mqtt_client = mqtt.Client()
mqtt_client.connect(broker)
for i in range(100000):
mqtt_client.publish(topic, ‘Message {}’.format(i))
time.sleep(0.001)
mqtt_client.disconnect()
Bizi Linkedin'de Takip Et