Node-telegram-bot-api: i got polling_error

Created on 23 Jan 2019  Â·  17Comments  Â·  Source: yagop/node-telegram-bot-api

how can i fix this error :
error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: getaddrinfo EAI_FAIL api.telegram.org api.telegram.org:443"}

my simple code :
const TelegramBot = require('node-telegram-bot-api');
const token = '*';
const bot = new TelegramBot(token, {polling: true});

bot.on('message', (msg) => {
let Hi = "hi";
if (msg.text.toString().toLowerCase().indexOf(Hi) === 0) {
bot.sendMessage(msg.chat.id,"Hello dear user");
}
});

Most helpful comment

For Iranian, You can use SOCKS5 proxy with the socks5-https-client lib.

Example:

const TelegramBot = require('node-telegram-bot-api')
const Agent = require('socks5-https-client/lib/Agent')

const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {
    polling: true,
    request: {
        agentClass: Agent,
        agentOptions: {
            socksHost: process.env.PROXY_SOCKS5_HOST,
            socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
            // If authorization is needed:
            // socksUsername: process.env.PROXY_SOCKS5_USERNAME,
            // socksPassword: process.env.PROXY_SOCKS5_PASSWORD
        }
    }
})

All 17 comments

Insert in your code this:

bot.on("polling_error", (msg) => console.log(msg));

It will give you more info about the error.

bot.on("polling_error", (msg) => console.log(msg));

i do this, but i cant resolve my problem yet

Does this printed something?

Does this printed something?
yep,
here is :

See https://github.com/yagop/node-telegram-bot-api/issues/319. internal\modules\cjs\loader.js:689:30
error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: getaddrinfo EAI_FAIL api.telegram.org api.telegram.org:443"}
Unhandled rejection RequestError: Error: getaddrinfo EAI_FAIL api.telegram.org api.telegram.org:443
at new RequestError (C:\Users\User\WebstormProjects\botnode_modules\request-promise-core\liberrors.js:14:15)
at Request.plumbing.callback (C:\Users\User\WebstormProjects\botnode_modules\request-promise-core\lib\plumbing.js:87:29)
at Request.RP$callback [as _callback] (C:\Users\User\WebstormProjects\botnode_modules\request-promise-core\lib\plumbing.js:46:31)
at self.callback (C:\Users\User\WebstormProjects\botnode_modules\request\request.js:185:22)
at Request.emit (events.js:182:13)
at Request.onRequestError (C:\Users\User\WebstormProjects\botnode_modules\request\request.js:881:8)
at ClientRequest.emit (events.js:182:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

This error indicated the Github issue to read, the #319. Read it, it should have the answer to your problem.

This error indicated the Github issue to read, the #319. Read it, it should have the answer to your problem.

i was do it,
but i cant solve my problem?
what is your idea about it?
can you help me?

Try to insert this above all the code:

process.env.NTBA_FIX_319 = 1;

Try to insert this above all the code:

process.env.NTBA_FIX_319 = 1;

i do it
but it dos not help me

I don't know. Maybe @kamikazechaser knows better the reason or has some better ideas.

@kamikazechaser
can you help me?

@alexandercerutti

thank you so about for your help
i solve this problem.
that reason was my country :)

in my country telegram was banned by gov. and i solve this problem by changing my IP

Oh okay! Perfect! Please, close this issue as you resolved! @MojtabaRazmi :)

For Iranian, You can use SOCKS5 proxy with the socks5-https-client lib.

Example:

const TelegramBot = require('node-telegram-bot-api')
const Agent = require('socks5-https-client/lib/Agent')

const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {
    polling: true,
    request: {
        agentClass: Agent,
        agentOptions: {
            socksHost: process.env.PROXY_SOCKS5_HOST,
            socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
            // If authorization is needed:
            // socksUsername: process.env.PROXY_SOCKS5_USERNAME,
            // socksPassword: process.env.PROXY_SOCKS5_PASSWORD
        }
    }
})

thanks a lot about your helpful email
best wishes

On Thu, Jan 24, 2019 at 9:14 PM Sedric Heidarizarei <
[email protected]> wrote:

For Iranian, You can use SOCKS5 proxy with the socks5-https-client lib.

Example:

const TelegramBot = require('node-telegram-bot-api')const Agent = require('socks5-https-client/lib/Agent')
const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {
polling: true,
request: {
agentClass: Agent,
agentOptions: {
socksHost: process.env.PROXY_SOCKS5_HOST,
socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
// If authorization is needed:
// socksUsername: process.env.PROXY_SOCKS5_USERNAME,
// socksPassword: process.env.PROXY_SOCKS5_PASSWORD
}
}
})

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yagop/node-telegram-bot-api/issues/696#issuecomment-457289714,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AoI1WyRItkSNhIi0H7XL6R3XiB5NAuo2ks5vGfDlgaJpZM4aPNfN
.

For Iranian, You can use SOCKS5 proxy with the socks5-https-client lib.

Example:

const TelegramBot = require('node-telegram-bot-api')
const Agent = require('socks5-https-client/lib/Agent')

const bot = new TelegramBot(process.env.TELEGRAM_API_TOKEN, {
  polling: true,
  request: {
      agentClass: Agent,
      agentOptions: {
          socksHost: process.env.PROXY_SOCKS5_HOST,
          socksPort: parseInt(process.env.PROXY_SOCKS5_PORT),
          // If authorization is needed:
          // socksUsername: process.env.PROXY_SOCKS5_USERNAME,
          // socksPassword: process.env.PROXY_SOCKS5_PASSWORD
      }
  }
})

thank you
it is DONE!

Salom. agar siz joylagan hosting sizga ssl sertifikat bermagan bo'lsa shunday xatolik berayapdi.

Ayrim Saytlardagi ma'lumotlarda esa bu bevosita vpn bilan bog'liq.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacopocappelli1989 picture jacopocappelli1989  Â·  4Comments

Hostile picture Hostile  Â·  3Comments

mbrammer picture mbrammer  Â·  3Comments

antonrifco picture antonrifco  Â·  3Comments

lenny76 picture lenny76  Â·  3Comments