yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.13k stars 1.49k forks source link

Polling Error: EFATAL #1136

Open TheRebo opened 9 months ago

TheRebo commented 9 months ago

Please help me!, error below happen when running the bot for the first time! :

RequestError: AggregateError at new RequestError (/home/kali/Bot-Telegram-Password-Manager/node_modules/request-promise-core/lib/errors.js:14:15) at plumbing.callback (/home/kali/Bot-Telegram-Password-Manager/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/home/kali/Bot-Telegram-Password-Manager/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/kali/Bot-Telegram-Password-Manager/node_modules/request/request.js:185:22) at Request.emit (node:events:514:28) at Request.onRequestError (/home/kali/Bot-Telegram-Password-Manager/node_modules/request/request.js:877:8) at ClientRequest.emit (node:events:514:28) at TLSSocket.socketErrorListener (node:_http_client:495:9) at TLSSocket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'EFATAL' }

Redskullvue commented 9 months ago

This can be caused by connection Problem try this repo hope it helps https://github.com/yagop/node-telegram-bot-api/issues/766

ngohuunam commented 9 months ago

Hi, I have this error, how can I handle this? It crash my app

jinsankim commented 8 months ago

I have same error. The error happens with nodejs v20 and ubuntu 22.04. With nodejs v20 and mac, there is no error. :(

jinsankim commented 8 months ago

@TheRebo Please could you share the environment?

blacktem12 commented 8 months ago

I have same error. The error happens with nodejs v20 and ubuntu 20.04.

cryptomatictrader999 commented 6 months ago

Same here. NodeJS v20 + Ubuntu 22.04.

richardscull commented 6 months ago

Any update on this?

Pragnesh8122001 commented 6 months ago

I am facing this same error in Ubuntu but I can run this code in replit and also works on Mac. Has anyone found the solution?

lalitkumawat1m commented 6 months ago

I'm also facing this error how to solve this please help me

Pragnesh8122001 commented 6 months ago

I'm also facing this error how to solve this please help me

Are you facing this error in Linux?

lalitkumawat1m commented 5 months ago

I'm also facing this error how to solve this please help me

Are you facing this error in Linux?

No I'm getting this error in windows 11

Piero87 commented 5 months ago

same problem here

linhdareal15 commented 5 months ago

same problem here on VPS ubuntu 22.04 - nodejs, all of my services were down because that error without any reason

Pragnesh8122001 commented 5 months ago

I'm also facing this error how to solve this please help me

Are you facing this error in Linux?

No I'm getting this error in windows 11

I used VPN and it started working.

hyeongirlife commented 5 months ago

I'm also facing this error how to solve this please help me

Are you facing this error in Linux?

No I'm getting this error in windows 11

I used VPN and it started working.

could you tell me detail?

felipegbot commented 5 months ago

i was facing the same error but with nestgram, i managed to fix it by downgrading from nodejs v20 to v18, and started using proton VPN

thetrung commented 4 months ago

Same with Ubuntu 20.04 + Node 20.

andreyLed commented 4 months ago

Same with Ubuntu 22.04 + Node v20.11.1

The application starts and works fine for a while. But at some point this error occurs and everything crashes.

BUT Ubuntu 20.04.6 + v18.7.0 Everything works great

PANCHO7532 commented 3 months ago

I think I solved it, apparently you need to force IPv4 via agentOptions on the request API, like so:

const botToken = "123123123:testAAAAA";
const telegramAPI = require("node-telegram-bot-api");
const bot = new telegramAPI(config.botToken, { polling: true, request: {
    agentOptions: {
        keepAlive: true,
        family: 4
    }
}});
bot.on("message", async function(msg) {
    await bot.sendMessage(msg.chat.id, "test");
});

And then it works fine. There has to be something really really wrong on how SSL requests are made on these libraries or the underlying http(s) infrastructure of node, since the bot indeed does request to an IPv4 address to Telegram despite this setting not being present but the server instantly replies with an RST. Basically, if your ISP just doesn't support IPv6 yet (and you don't have an IPv6 public address), you'll be getting this unless you force IPv4 explicitly somehow. It's also happening on telegraf but haven't managed to force IPv4 explicitly yet since it doesn't seem to expose a way to modify the http(s) agent.

Some related issues: yagop/node-telegram-bot-api#1156 telegraf/telegraf#1961 telegraf/telegraf#1917

Ali-Script commented 2 months ago

same with windows 10 can anyone help?

TheRebo commented 2 months ago

I think I solved it, apparently you need to force IPv4 via agentOptions on the request API, like so:

const botToken = "123123123:testAAAAA";
const telegramAPI = require("node-telegram-bot-api");
const bot = new telegramAPI(config.botToken, { polling: true, request: {
    agentOptions: {
        keepAlive: true,
        family: 4
    }
}});
bot.on("message", async function(msg) {
    await bot.sendMessage(msg.chat.id, "test");
});

And then it works fine. There has to be something really really wrong on how SSL requests are made on these libraries or the underlying http(s) infrastructure of node, since the bot indeed does request to an IPv4 address to Telegram despite this setting not being present but the server instantly replies with an RST. Basically, if your ISP just doesn't support IPv6 yet (and you don't have an IPv6 public address), you'll be getting this unless you force IPv4 explicitly somehow. It's also happening on telegraf but haven't managed to force IPv4 explicitly yet since it doesn't seem to expose a way to modify the http(s) agent.

Some related issues: #1156 telegraf/telegraf#1961 telegraf/telegraf#1917

Thank you very much!

uziins commented 2 months ago

I think I solved it, apparently you need to force IPv4 via agentOptions on the request API, like so:

const botToken = "123123123:testAAAAA";
const telegramAPI = require("node-telegram-bot-api");
const bot = new telegramAPI(config.botToken, { polling: true, request: {
    agentOptions: {
        keepAlive: true,
        family: 4
    }
}});
bot.on("message", async function(msg) {
    await bot.sendMessage(msg.chat.id, "test");
});

And then it works fine. There has to be something really really wrong on how SSL requests are made on these libraries or the underlying http(s) infrastructure of node, since the bot indeed does request to an IPv4 address to Telegram despite this setting not being present but the server instantly replies with an RST. Basically, if your ISP just doesn't support IPv6 yet (and you don't have an IPv6 public address), you'll be getting this unless you force IPv4 explicitly somehow. It's also happening on telegraf but haven't managed to force IPv4 explicitly yet since it doesn't seem to expose a way to modify the http(s) agent.

Some related issues: #1156 telegraf/telegraf#1961 telegraf/telegraf#1917

It works! Thank you

lwhuang commented 2 months ago

I think I solved it, apparently you need to force IPv4 via agentOptions on the request API, like so:

const botToken = "123123123:testAAAAA";
const telegramAPI = require("node-telegram-bot-api");
const bot = new telegramAPI(config.botToken, { polling: true, request: {
    agentOptions: {
        keepAlive: true,
        family: 4
    }
}});
bot.on("message", async function(msg) {
    await bot.sendMessage(msg.chat.id, "test");
});

And then it works fine. There has to be something really really wrong on how SSL requests are made on these libraries or the underlying http(s) infrastructure of node, since the bot indeed does request to an IPv4 address to Telegram despite this setting not being present but the server instantly replies with an RST. Basically, if your ISP just doesn't support IPv6 yet (and you don't have an IPv6 public address), you'll be getting this unless you force IPv4 explicitly somehow. It's also happening on telegraf but haven't managed to force IPv4 explicitly yet since it doesn't seem to expose a way to modify the http(s) agent.

Some related issues: #1156 telegraf/telegraf#1961 telegraf/telegraf#1917

it works, thank you very much

frantrick commented 2 months ago

Hey guys, a little update for request type, is missing the URL parameter:

request: { agentOptions: { keepAlive: true, family: 4 }, url: "https://api.telegram.org", }

PANCHO7532 commented 2 months ago

Hey guys, a little update for request type, is missing the URL parameter:

request: { agentOptions: { keepAlive: true, family: 4 }, url: "https://api.telegram.org", }

I think this is unnecessary since node-telegram-bot-api already fills that parameter with the correct URL, unless you're doing something really customized for your use-case you shouldn't do that.

nafifurqon commented 2 months ago

I am facing the same error with nodejs v20 and ubuntu 22.04 on virtual machine (VM). but there is no error on my local computer with nodejs v20 and macos. I downgraded the nodejs version to v14 on VM and it worked fine.

Ligengxin96 commented 2 weeks ago

I think I solved it, apparently you need to force IPv4 via agentOptions on the request API, like so:

const botToken = "123123123:testAAAAA";
const telegramAPI = require("node-telegram-bot-api");
const bot = new telegramAPI(config.botToken, { polling: true, request: {
    agentOptions: {
        keepAlive: true,
        family: 4
    }
}});
bot.on("message", async function(msg) {
    await bot.sendMessage(msg.chat.id, "test");
});

And then it works fine. There has to be something really really wrong on how SSL requests are made on these libraries or the underlying http(s) infrastructure of node, since the bot indeed does request to an IPv4 address to Telegram despite this setting not being present but the server instantly replies with an RST. Basically, if your ISP just doesn't support IPv6 yet (and you don't have an IPv6 public address), you'll be getting this unless you force IPv4 explicitly somehow. It's also happening on telegraf but haven't managed to force IPv4 explicitly yet since it doesn't seem to expose a way to modify the http(s) agent.

Some related issues: #1156 telegraf/telegraf#1961 telegraf/telegraf#1917

Thanks, It works for me.