@KoPeYkAMerlow

Из-за чего может быть ошибка Connection timed out в discord.js?

Есть discord бот (ниже: main.ts)
import {Client, GatewayIntentBits, SlashCommandBuilder, TextChannel} from "discord.js";
import {StartCommandCreator, StartExecutor} from "./commands/slashCommands/startCommand";
import slashCommandHandler from "./handlers/slashCommands";
import selectStringHandler from "./handlers/selectString";
import button from "./handlers/buttonHandlers";
import modal from "./handlers/modalHandler";
import {resetLanguageCommandCreate} from "./commands/slashCommands/relanguageCommand";
import SqliteDatabase from "./classes/sqliteDatabaseClass";

const client = new Client({intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildBans,
        GatewayIntentBits.GuildModeration

]});

client.on('ready', async (message) => {
        // Create commands
        if (!client.application) return;

        await client.application.commands.create(StartCommandCreator); // start command
        await client.application.commands.create(resetLanguageCommandCreate); // reset language command

        const db = new SqliteDatabase()
        await db.initDatabase()
})

client.on('interactionCreate', async (message) => {
        if (!message) return;

        if (message.isCommand()) return slashCommandHandler(message)
        if (message.isStringSelectMenu()) return selectStringHandler(message)
        if (message.isButton()) return button(message)
        if (message.isModalSubmit()) return modal(message)

})

const env = process.env

client.login(env.BOT_TOKEN);

export const mysqlData = {
        user: env.MYSQL_USER,
        host: env.MYSQL_HOST,
        password: env.MYSQL_PASSWORD,
        database: env.MYSQL_DATABASE,
        port: Number(env.MYSQL_PORT)
}


Когда я запускаю его локально, то все работает, но когда делаю это в докер-контейнере на сервере (gitlab, pipline), то получаю ошибку:

ConnectTimeoutError: Connect Timeout Error (attempted addresses: 162.159.128.233:443, 162.159.135.232:443, 162.159.138.232:443, 162.159.137.232:443, 162.159.136.232:443)
     at onConnectTimeout (/bot/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:190:24)
     at /bot/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:133:46
     at Immediate._onImmediate (/bot/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:174:9)
     at processImmediate (node:internal/timers:478:21) {
   code: 'UND_ERR_CONNECT_TIMEOUT'
 }


При том, что когда я выполняю команду ping discord.js, то получаю ответ, что говорит об присутствии интернета в контейнере

PING discord.com (162.159.137.232): 56 data bytes
64 bytes from 162.159.135.232: seq=0  ttl=57  time=5.412
64 bytes from 162.159.135.232: seq=1  ttl=57  time=5.672
64 bytes from 162.159.135.232: seq=2  ttl=57  time=5.485
64 bytes from 162.159.135.232: seq=3  ttl=57  time=5.656
64 bytes from 162.159.135.232: seq=4  ttl=57  time=5.434
64 bytes from 162.159.135.232: seq=5  ttl=57  time=5.426
64 bytes from 162.159.135.232: seq=6  ttl=57  time=5.479
  • Вопрос задан
  • 213 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы