WebSocketManager disconnects 30-60 minutes at a time
See original GitHub issueWhich package is this bug report for?
ws
Issue description
Running WebSocketManager for a bot on my own personal Discord server
Tested this locally and on a staging within an EC2 instance – the same issue applies
Randomly throughout the day this will occur and could go on for upwards of 30-60 minutes.
How can I ensure no/minimal disconnection? (Code sample below – very straightforward implementation)
Connecting to [wss://gateway.discord.gg?v=10&encoding=json](wss://gateway.discord.gg/?v=10&encoding=json)
info: Debug
Waiting for event hello for 60000ms
info: Heartbeat
info: Debug
Starting to heartbeat every 41250ms
info: Debug
Identifying
shard id: 0
shard count: 1
intents: 34305
compression: none
info: Debug
Disconnected normally from code 1000
info: Debug
Destroying shard
Reason: Got disconnected by Discord
Code: 1000
Recover: Reconnect
info: Debug
Connecting to [wss://gateway.discord.gg?v=10&encoding=json](wss://gateway.discord.gg/?v=10&encoding=json)
info: Debug
Waiting for event hello for 60000ms
info: Heartbeat
info: Debug
Starting to heartbeat every 41250ms
info: Debug
Identifying
shard id: 0
shard count: 1
intents: 34305
compression: none
info: Debug
Disconnected normally from code 1000
info: Debug
Destroying shard
Reason: Got disconnected by Discord
Code: 1000
Recover: Reconnect
info: Debug
Connecting to [wss://gateway.discord.gg?v=10&encoding=json](wss://gateway.discord.gg/?v=10&encoding=json)
info: Debug
Waiting for event hello for 60000ms
info: Heartbeat
info: Debug
Starting to heartbeat every 41250ms
info: Debug
Identifying
shard id: 0
shard count: 1
intents: 34305
compression: none
info: Debug
Disconnected normally from code 1000
info: Debug
Destroying shard
Reason: Got disconnected by Discord
Code: 1000
Recover: Reconnect
info: Debug
Connecting to [wss://gateway.discord.gg?v=10&encoding=json](wss://gateway.discord.gg/?v=10&encoding=json)
info: Debug
Waiting for event hello for 60000ms
info: Heartbeat
info: Debug
Starting to heartbeat every 41250ms
info: Debug
Identifying
shard id: 0
shard count: 1
intents: 34305
compression: none
Code sample
if (!authToken) throw Error('BOT AuthToken not set');
const rest = new REST().setToken(authToken);
const manager = new WebSocketManager({
handshakeTimeout: 20000,
token: authToken,
intents,
rest,
});
manager.setStrategy(new SimpleShardingStrategy(manager));
manager.addListener(WebSocketShardEvents.Debug, async (payload: { message: string }) =>
logger.info(`Debug\n${payload.message}`)
);
manager.addListener(WebSocketShardEvents.Ready, () => logger.info('Ready'));
manager.addListener(WebSocketShardEvents.Hello, () => logger.info('Heartbeat'));
manager.addListener(WebSocketShardEvents.Resumed, () => logger.info('Resumed'));
manager.addListener(
WebSocketShardEvents.Dispatch,
(
event: {
data: GatewayDispatchPayload;
} & {
shardId: number;
}
) => logEvent(event.data)
);
await manager.connect();
Package version
14.3.0
Node.js version
18.6.0
Operating system
No response
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
Message, Reaction
Which gateway intents are you subscribing to?
Guilds, GuildMessages, GuildMessageReactions, MessageContent
I have tested this issue on a development release
No response
Issue Analytics
- State:
- Created a year ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
What Is 3060 Minutes In Hours? (3060 min to hr)
To convert 3060 minutes into hours we have to multiply 3060 by the conversion factor in order to get the amount from minutes...
Read more >3060 minutes to hours - Unit Converter
This conversion of 3,060 minutes to hours has been calculated by multiplying 3,060 minutes by 0.0166 and the result is 51 hours.
Read more >3060 Minutes to Hours
3060 minutes = 51 hours and 0 minutes. This alternative conversion is way more common in daily life!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
packages/ws/src/ws/WebSocketShard.ts
- mainly theonClose
handler and thedestroy
method.discord.js
(mainlib) does not currently use@discordjs/ws
, it has its own own WS implementation (the “old” one), so no, those changes do not help at all at this time, but they will potentially will in the future when the main library starts using the ws package.