Random disconnection

My WS Connection was closed randomly. Debug logs are as follows:
[WS => Shard 0] [HeartbeatTimer] Didn't receive a heartbeat ack last time, assuming zombie connection. Destroying and reconnecting.
Status : 0
Sequence : 249614006
Connection State: OPEN
[WS => Shard 0] [DESTROY]
Close Code : 4009
Reset : true
Emit DESTROYED: true
[WS => Shard 0] [HeartbeatTimer] Didn't receive a heartbeat ack last time, assuming zombie connection. Destroying and reconnecting.
Status : 0
Sequence : 249614006
Connection State: OPEN
[WS => Shard 0] [DESTROY]
Close Code : 4009
Reset : true
Emit DESTROYED: true
I know this is normal, but this makes my shard go down. Can you tell me about some preventions for this? Like if possible, can I make smth like which automatically respawns the shard?
7 Replies
d.js toolkit
d.js toolkit15mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Kinect3000
Kinect300015mo ago
It says it’s reconnecting Are you calling guild.members.fetch() or updating presence often?
Elitex
Elitex14mo ago
Nope I have nothing like that... it stops, until restarted Can it go like, If I add a shardDisconnect Event to all shards, and whenever one of them dies, I respawn the shard? ok
const client = new Client({
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 7200, // Every 2 hours...
lifetime: 3600, // Remove messages older than 60 minutes.
},
invites : {
interval: 3600,
lifetime: 1800
}
},
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
ApplicationCommandManager: {maxSize: 100},
GuildBanManager: {maxSize: 100},
GuildStickerManager: {maxSize: 0},
GuildScheduledEventManager: {maxSize: 0},
ReactionUserManager: {maxSize: 100},
PresenceManager: {maxSize: 0},
GuildInviteManager: {maxSize: 0},
ReactionManager: {maxSize: 100},
GuildEmojiManager: {maxSize: 100},
GuildMemberManager: {maxSize: 250},
BaseGuildEmojiManager: {maxSize: 150}
}),
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Message,
Partials.GuildMember,
Partials.GuildScheduledEvent,
Partials.Reaction,
Partials.ThreadMember,
Partials.User
],
presence: {
activities: [{name: `/help | Winter Build`, type: 0}],
status: "idle"
},
allowedMentions:{
repliedUser: false,
parse: ['users','roles','everyone']
}
});
const client = new Client({
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 7200, // Every 2 hours...
lifetime: 3600, // Remove messages older than 60 minutes.
},
invites : {
interval: 3600,
lifetime: 1800
}
},
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
ApplicationCommandManager: {maxSize: 100},
GuildBanManager: {maxSize: 100},
GuildStickerManager: {maxSize: 0},
GuildScheduledEventManager: {maxSize: 0},
ReactionUserManager: {maxSize: 100},
PresenceManager: {maxSize: 0},
GuildInviteManager: {maxSize: 0},
ReactionManager: {maxSize: 100},
GuildEmojiManager: {maxSize: 100},
GuildMemberManager: {maxSize: 250},
BaseGuildEmojiManager: {maxSize: 150}
}),
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Message,
Partials.GuildMember,
Partials.GuildScheduledEvent,
Partials.Reaction,
Partials.ThreadMember,
Partials.User
],
presence: {
activities: [{name: `/help | Winter Build`, type: 0}],
status: "idle"
},
allowedMentions:{
repliedUser: false,
parse: ['users','roles','everyone']
}
});
Nope, I don't have any custom event only what I have are of https, and they are not connected to shards on this : https://discord.js.org/#/docs/main/stable/class/WebSocketShard ? nope I am new to sharding..... pls help me out, if there is somthing wrong :_ I have 1975 servers on my bot on how.. I was following the guide yes
const { ShardingManager } = require('discord.js');
require('dotenv').config();

let manager = new ShardingManager('./src/bot.js', {
token: process.env.token
});

manager.on('shardCreate', shard => {
console.log(`[SHARD MANAGER]: Launched shard #${shard.id}`);
});

manager.spawn({timeout: -1});

process.on('unhandledRejection', async (err, cause) => {
if(err.code == 10008 || err.code == 10062) return;
console.log(`[Uncaught Rejection]: ${err}`.bold.red);
console.log(cause);
});

process.on('uncaughtException', async err => {
console.log(`[Uncaught Exception] ${err}`.bold.red);
});
const { ShardingManager } = require('discord.js');
require('dotenv').config();

let manager = new ShardingManager('./src/bot.js', {
token: process.env.token
});

manager.on('shardCreate', shard => {
console.log(`[SHARD MANAGER]: Launched shard #${shard.id}`);
});

manager.spawn({timeout: -1});

process.on('unhandledRejection', async (err, cause) => {
if(err.code == 10008 || err.code == 10062) return;
console.log(`[Uncaught Rejection]: ${err}`.bold.red);
console.log(cause);
});

process.on('uncaughtException', async err => {
console.log(`[Uncaught Exception] ${err}`.bold.red);
});
Elitex
Elitex14mo ago
ah my bad 😦 should updating to latest fix dam idea ? Digital Ocean on a VPS, over pm2 wait lemmi cross check them
Elitex
Elitex14mo ago
its just filled with all buffer warnings
Elitex
Elitex14mo ago
ig I fount it.... Can you let me know, how much time it takes to reconnect a shard ? ohk Thanks for the help and info..