#Fix Connect Timeout Error
29 messages · Page 1 of 1 (latest)
My dev-machine is Windows Server 2019 in Tencent Cloud Shanghai
I have opened all firewall ports (1-65535) and allowed any IPV4 inbound and outbound
// Require the necessary discord.js classes
const { Client, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
// Login to Discord with your client's token
client.login(token);
@teal dragon@lunar vale this still an issue?
if so, that needs some debug logs
@lunar vale doesn't look sharded, so i assume it's not shard specific?
i can confirm that is a huge issue caused on sharded bots
Can you specify the exact request thats timeout or if it is all of them??
Y sometimes bot crash with that
That doesn’t tell us what the request is/was that timed out sadly. Got debug logs of it happening?
@exotic ocean , could you add this to your main file:
process.on('uncaughtException', console.trace).on('unhandledRejection', console.trace);
And see if it provides a more accurate stack trace
If you seen fit, use a bin to send here
this is unrelated to discord.js, you are using fetch somewhere
Wdym? Bc djs uses undici under the hood
And the error is fixable by adding a custom agent to rest
yes I added undici to djs
that error occurs when using fetch; djs uses undici's request
Request doesn't use fetch under thw hood?
Bc they say the error is fixed when you set a custom agent to the Rest client
Doesn't make sense the error beeing outside Rest
Nice
i aint using fetch anywhere
will do
everyone who has updated to discord.js V14 and on console get this: (It's an error about connection time, it seems that it takes time to connect, I don't know what but they should fix it soon)
ConnectTimeoutError: Connect Timeout Error
code: 'UND_ERR_CONNECT_TIMEOUT'
```You can solve it with the following```ts
import { Client } from 'discord.js'
import { Agent } from 'undici'
const client = new Client({ ... })
const agent = new Agent({
connect: {
timeout: 30000
}
})
client.rest.setAgent(agent)
await client.login('...')
Don't think this is related to djs