Main Question:
How do I have no downtime for the bot?
When a token expires and I have to refresh it, I seem to also need to close the websocket connection and reopen it with the new oAuth token.
Generally my flow is
connect websocket with oAuth token
wait for 401 / ping pong failure
close websocket connection
get new oAuth token using refresh_token
reopen websocket connection
Which, depending on internet connection, ranges from about 1-5 seconds of downtime, about every 4 hours.
This is rarely an issue, as 5 seconds of chat loss isn’t detrimental… but it does annoy me that I can’t figure out a solution to keep the connection open indefinitely.
… So yeah. am I missing something extremely simple to keep the connection open?
A token to read/write to chat only needs to be valid at the moment you connect to chat. So you can keep going for days with the original token being dead.
You’ll just need the new token for API calls (such as banning users)
When you refresh the token you do not need to reconnect to chat