-
-
Save tcastelly/2b3b2b82169c212d2ce3ff7e1f7e0236 to your computer and use it in GitHub Desktop.
mq-reconnect.js
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
... | |
conn.on("close", function() { | |
winston.error("-> mq.connection: close event received"); | |
mq.channel = null; | |
// Try to reconnect every X seconds | |
let timer = setInterval(function () { | |
winston.info('-> mq.connection: trying to reconnect...'); | |
mq.connect((err) => { | |
if (err) { | |
winston.error(util.format("-> mq.connection: reconnection failed [%s]", err.message)); | |
} else { | |
winston.info(util.format("-> app: mq.connect succeeded")); | |
clearInterval(timer); | |
} | |
}); | |
}, 3000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment