Add a listener for the 'close' event and reconnect when it’s fired. The disconnects could be caused by a lot of things, but as long as you’re replying to PINGs (which the module is) and staying below 20 messages in 30 seconds (or 100 messages on channels where the bot has moderator status), it’s not your fault. Setting floodProtectionDelay to 1500 will satisfy the lower limit.