Skip to content

Instantly share code, notes, and snippets.

@karlp
Created February 16, 2018 12:24
Show Gist options
  • Save karlp/a2d50d0bd49313d617c9343b41caad73 to your computer and use it in GitHub Desktop.
Save karlp/a2d50d0bd49313d617c9343b41caad73 to your computer and use it in GitHub Desktop.
mosquitto simple speed
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>
<script>
client = new Paho.MQTT.Client("somehost", 8083, "clientId");
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
client.connect({onSuccess:onConnect});
function onConnect() {
console.log("onConnect");
client.subscribe("hoho/#");
}
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
}
</script>
while true; do mosquitto_pub -t "hoho/$(date +%s)" -m x; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment