Last active
December 15, 2015 02:39
-
-
Save ralight/5188913 to your computer and use it in GitHub Desktop.
Create 1000 mqtt clients (in 1000 threads) to test broker connections.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import mosquitto | |
import time | |
def on_connect(mosq, obj, rc): | |
print("Connected: "+mosq._client_id) | |
def on_disconnect(mosq, obj, rc): | |
print("Disconnected: "+mosq._client_id + " ("+str(rc)+")") | |
for i in range(0, 1000): | |
mosq = mosquitto.Mosquitto() | |
mosq.on_connect = on_connect | |
mosq.on_disconnect = on_disconnect | |
mosq.connect("localhost", 1883, 60) | |
mosq.subscribe("$SYS/#", 0) | |
mosq.loop_start() | |
while True: | |
time.sleep(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
import subprocess | |
for i in range(0, 1000): | |
client = subprocess.Popen(('mosquitto_sub', '-t', '$SYS/#', '-p', '1883', '-h', 'localhost')) | |
while True: | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment