Created
January 14, 2019 10:09
-
-
Save lucj/949d8204bdc44d09d1ecd0462a564dd4 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 | |
const 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