-
-
Save adamvr/5714227 to your computer and use it in GitHub Desktop.
Testing for mqttjs reconnection
This file contains 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
var mqtt = require('./'); | |
var client = mqtt.createClient(); | |
client.on('connect', function() { | |
console.log('connected'); | |
}); | |
client.on('close', function() { | |
console.log('close, dcing:', client.disconnecting); | |
}); | |
client.on('error', function(err) { | |
console.log(error); | |
}); | |
var count = 5; | |
var t = setInterval(function () { | |
if (!count--) { | |
client.end(); | |
} else { | |
console.log('shutting connection'); | |
client.stream.end(); | |
} | |
}, 3000); | |
t.unref(); | |
var client2 = mqtt.createClient(); | |
client2.end(); | |
client2.on('connect', function() { | |
console.log('client2 connect'); | |
}); | |
client2.on('close', function() { | |
console.log('client2 close, dcing:', client2.disconnecting); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment