RocketChat / Rocket.Chat.js.SDK

Utility for apps and bots to interact with Rocket.Chat via DDP and/or API
MIT License
136 stars 94 forks source link

Connection gets stuck when rocketchat instance is down #163

Open evakdev opened 1 year ago

evakdev commented 1 year ago

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?