Rocket.Chat.js.SDK
Rocket.Chat.js.SDK copied to clipboard
Connection gets stuck when rocketchat instance is down
I've set a bot to listen to messages of a rocketchat instance:
const { driver } = RocketChat
await driver.connect({
host: url.hostname,
useSsl: url.protocol === "https:"
})
await driver.login({ username: url.username, password: url.password })
await driver.joinRooms(state.rocketchatRooms)
await driver.subscribeToMessages()
However, if for any reason the connection to the rocketchat instance is closed (e.g. if it is down), then my bot will get stuck. it will not restart the connection nor will it stop working. I have to manually restart it to fix the issue.
I believe this could be handled inside the sdk. Is there such an implementation? If not, what would be the best way to handle this issue? For example, how could I make it so that it restarts the connection when it is closed?