discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.5k stars 3.97k forks source link

using @discordjs/proxy-container on docker desktop and got the error Error: connect ETIMEDOUT 108.160.173.207:443 #9901

Closed msnmask closed 1 year ago

msnmask commented 1 year ago

Which package is this bug report for?

proxy-container

Issue description

"discord.js": "^14.13.0",

Node.js v16.19.1.

javaScript project

    clientConnect() {
        this.client = new Client({
        intents: [
            GatewayIntentBits.Guilds,
            GatewayIntentBits.GuildMessages,
            GatewayIntentBits.MessageContent,
            GatewayIntentBits.GuildMembers,
        ],
        rest: {
            api: 'http://localhost:8080/api',
        }
    });
        this.client.login(process.env.DISCORD_TOKEN).then(res => {
            console.log('result', res);
            this.server.connect = true;
        }).catch(rej => {
            console.log('reject', rej, '\nreconnecting');
            this.server.connect = false;
            this.clientConnect();
        });
    }

the code is here

got the error :

reject Error: connect ETIMEDOUT 157.240.16.50:443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
  errno: -4039,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '157.240.16.50',
  port: 443
}
reconnecting

i run through the two steps guidline on discord.js/packages/proxy-container/README.md and here is the docker desktop image image

image

Code sample

clientConnect() {
        this.client = new Client({
        intents: [
            GatewayIntentBits.Guilds,
            GatewayIntentBits.GuildMessages,
            GatewayIntentBits.MessageContent,
            GatewayIntentBits.GuildMembers,
        ],
        rest: {
            api: 'http://localhost:8080/api',
        }
    });
        this.client.login(process.env.DISCORD_TOKEN).then(res => {
            console.log('result', res);
            this.server.connect = true;
        }).catch(rej => {
            console.log('reject', rej, '\nreconnecting');
            this.server.connect = false;
            this.clientConnect();
        });
    }

Versions

"discord.js": "^14.13.0",

Node.js v16.19.1.

Issue priority

High (immediate attention needed)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildMessages

I have tested this issue on a development release

No response

didinele commented 1 year ago

This is a networking issue on your end. From what I can gather, you're also running your bot in docker? If so, localhost won't behave like you expect it to by default. I recommend reading up on this: https://docs.docker.com/network - the example in our README assumes you just run your bot locally, on the host system.

Either way, your code sample is not enough for us to reproduce this issue.

msnmask commented 1 year ago

2023-10-19 15:04:11 node:internal/process/promises:288 2023-10-19 15:04:11 triggerUncaughtException(err, true / fromPromise /); 2023-10-19 15:04:11 ^ 2023-10-19 15:04:11 2023-10-19 15:04:11 Error: Client network socket disconnected before secure TLS connection was established 2023-10-19 15:04:11 at connResetException (node:internal/errors:720:14) 2023-10-19 15:04:12 Listening on port 8080 2023-10-19 15:04:24 Listening on port 8080 2023-10-19 15:04:11 at TLSSocket.onConnectEnd (node:_tls_wrap:1655:19) 2023-10-19 15:04:11 at TLSSocket.emit (node:events:529:35) 2023-10-19 15:04:11 at endReadableNT (node:internal/streams/readable:1368:12) 2023-10-19 15:04:11 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { 2023-10-19 15:04:11 code: 'ECONNRESET', 2023-10-19 15:04:11 path: undefined, 2023-10-19 15:04:11 host: 'discord.com', 2023-10-19 15:04:11 port: 443, 2023-10-19 15:04:11 localAddress: null 2023-10-19 15:04:11 } 2023-10-19 15:04:11 2023-10-19 15:04:11 Node.js v18.18.2 2023-10-19 15:04:23 node:internal/process/promises:288 2023-10-19 15:04:23 triggerUncaughtException(err, true / fromPromise /); 2023-10-19 15:04:23 ^ 2023-10-19 15:04:23 2023-10-19 15:04:23 ConnectTimeoutError: Connect Timeout Error 2023-10-19 15:04:23 at onConnectTimeout @./node_modules/undici/lib/core/connect.js:186:24) 2023-10-19 15:04:23 at @./node_modules/undici/lib/core/connect.js:133:46 2023-10-19 15:04:23 at Immediate._onImmediate @.***/node_modules/undici/lib/core/connect.js:174:9) 2023-10-19 15:04:23 at process.processImmediate (node:internal/timers:476:21) { 2023-10-19 15:04:23 code: 'UND_ERR_CONNECT_TIMEOUT' 2023-10-19 15:04:23 } 2023-10-19 15:04:23 2023-10-19 15:04:23 Node.js v18.18.2 ok..so what is this then ?this is from your docker contiainer . inside ,your docker contianer . i done these : first , [cid:8c7f3c8e-7093-4105-b563-d63fb301d659] the docker config .

{ "credsStore": "desktop", "proxies": { "default": { "httpProxy": "http://127.0.0.1:7890", "httpsProxy": "http://127.0.0.1:7890" } } }

and im using clash to open the proxy on http://127.0.0.1:7890 like this [cid:05bddda3-4d26-4740-963e-d684707388e6] so ... what is wrong . i dont understand ..


发件人: DD @.> 发送时间: 2023年10月19日 0:24 收件人: discordjs/discord.js @.> 抄送: msnmask @.>; Author @.> 主题: Re: [discordjs/discord.js] using @discordjs/proxy-container on docker desktop and got the error Error: connect ETIMEDOUT 108.160.173.207:443 (Issue #9901)

This is a networking issue on your end. From what I can gather, you're also running your bot in docker? If so, localhost won't behave like you expect it to by default. I recommend reading up on this: https://docs.docker.com/network

Either way, your code sample is not enough for us to reproduce this issue.

― Reply to this email directly, view it on GitHubhttps://github.com/discordjs/discord.js/issues/9901#issuecomment-1768902659, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOAUVX6ZENZXBQZ6O3OBP63X777ELAVCNFSM6AAAAAA6FGV4UCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRYHEYDENRVHE. You are receiving this because you authored the thread.Message ID: @.***>

Jiralite commented 1 year ago

Discussed further at: