alta-vr / js-tale

GNU General Public License v3.0
2 stars 10 forks source link

Bot crashes approximately one hour after coming online #3

Closed mdingena closed 3 years ago

mdingena commented 3 years ago

Context

When the bot starts, it will receive an access token with which it can create a websocket connection. It seems that this websocket connecation expires roughly every 10 minutes, and js-tale diligently recreates the connection automatically.

But after 6 to 7 recreations (so after about an hour) the next recreation will fail with a 401 Unauthorized status code. Worse, this exception is unhandled which means the whole bot comes crashing down.

Observation

5/7/2021, 11:57:07 AM - [ApiConnection] Setting up https client
5/7/2021, 11:57:07 AM - [ApiConnection] Deconding token
5/7/2021, 11:57:07 AM - [ApiConnection] User ID: 1529569283
5/7/2021, 11:57:07 AM - [ApiConnection] Username: voodoo mod
5/7/2021, 11:57:08 AM - [LiveList] Subscribed to groups delete
5/7/2021, 11:57:08 AM - [LiveList] Subscribed to groups create
5/7/2021, 11:57:09 AM - [LiveList] Subscribed to invites delete
5/7/2021, 11:57:09 AM - [LiveList] Subscribed to invites create
5/7/2021, 11:57:09 AM - [GroupManager] Accepted all group invites
5/7/2021, 11:57:09 AM - [GroupManager] Enabling automatic console for all groups
5/7/2021, 11:57:09 AM - [Express] API listening on port 3000
5/7/2021, 11:57:32 AM - [Group] Joined 292966562 - Bot Test
5/7/2021, 11:57:32 AM - [Group] Enabling automatic console for Bot Test
5/7/2021, 11:57:33 AM - [GroupInvite] Accepted invite to Bot Test (292966562)
5/7/2021, 11:57:33 AM - [LiveList] Subscribed to Bot Test servers delete
5/7/2021, 11:57:33 AM - [LiveList] Subscribed to Bot Test servers create
5/7/2021, 11:57:33 AM - [Group] Subscribed to Bot Test status
5/7/2021, 12:07:33 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 12:17:49 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 12:28:06 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 12:38:23 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 12:48:40 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 12:58:56 PM - [SubscriptionManager] Websocket expired, recreating
5/7/2021, 1:09:13 PM - [SubscriptionManager] Websocket expired, recreating

C:\Users\Surrogator\code\att-voodoo-server\node_modules\ws\lib\websocket.js:604
      abortHandshake(
      ^
Error: Unexpected server response: 401

Desired outcome

js-tale uses the API's refresh token to request a new access token when the current access token is about to expire. Refreshing the access token will allow the bot to keep recreating websockets, so that it can run indefinitely.

Narmdo commented 3 years ago

Will need to investigate this further, but noticed an issue that would cause the refresh to only occur once.

I believe the expiration is 30 minutes, so that could explain the situation here.

mdingena commented 3 years ago

This appears to be fixed in v1.1.0 🎉

mdingena commented 3 years ago

This issue has resurfaced. The bot crashes roughly every hour as seen in my error logging: image Between 19 and 20 times per day for the last week.