Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polling Error: EFATAL #1136

Open
TheRebo opened this issue Oct 7, 2023 · 26 comments
Open

Polling Error: EFATAL #1136

TheRebo opened this issue Oct 7, 2023 · 26 comments

Comments

@TheRebo
Copy link

TheRebo commented Oct 7, 2023

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
Copy link

This can be caused by connection Problem try this repo hope it helps
#766

@ngohuunam
Copy link

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

@jinsankim
Copy link

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

@jinsankim
Copy link

@TheRebo Please could you share the environment?

@blacktem12
Copy link

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

@cryptomatictrader999
Copy link

Same here. NodeJS v20 + Ubuntu 22.04.

@richardscull
Copy link

Any update on this?

@Pragnesh8122001
Copy link

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
Copy link

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

@Pragnesh8122001
Copy link

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

Are you facing this error in Linux?

@lalitkumawat1m
Copy link

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
Copy link

Piero87 commented Jan 17, 2024

same problem here

@linhdareal15
Copy link

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

@Pragnesh8122001
Copy link

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
Copy link

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
Copy link

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
Copy link

Same with Ubuntu 20.04 + Node 20.

@andreyLed
Copy link

andreyLed commented Feb 23, 2024

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
Copy link

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

@Ali-Script
Copy link

same with windows 10 can anyone help?

@TheRebo
Copy link
Author

TheRebo commented Apr 13, 2024

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
Copy link

uziins commented Apr 25, 2024

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
Copy link

lwhuang commented Apr 28, 2024

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
Copy link

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
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests