kritzware/twitch-bot

EPIPE errors when disconnected from internet

Opened this issue · 1 comments

I assume this project's support is waning, but I wanted to reach out and see if anyone could tell me in what part of the bot.js throws an EPIPE error when internet connectivity is not found.
Anytime wifi gets disconnected or the computer goes to sleep, this library will disconnect and doesnt seem to have reconnection logic.

Anyone willing to lead me in the right direction?

My basic assumption is, if i have a channels array connected to the bot, and I get an EPIPE error, I need to manually call Bot.join on those channels again? Or perhaps reinstantiate the Bot all together?

Thanks in advance

Did you receive the error via the error event of the bot instance or was it unhandled?

Anyway, I assume if you encounter it you could just call _connect() on the Bot manually to reestablish a connection. You could also consider removing all listener callbacks via botInstance.irc.removeAllListeners() so that you do not have multiple callbacks for the same event registered when reconnecting with the same TLS socket instance.

So in case of error, you could do:

botInstance.irc.removeAllListeners()
await botInstance._connect()

And it should reconnect successfully, using your previous channels and auth token.