node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

Polling errors stalling the bot

Open peoro opened this issue 7 years ago • 2 comments

Every now and then my bot stops working, although the process is still up and running. When it happens, the last log message is always a polling error.

The last polling error before the bot stops working varies... Looking at my logs I can find:

  • ETELEGRAM: 502 Bad Gateway
  • connect ETIMEDOUT 149.154.167.220:443
  • connect ENETUNREACH 149.154.167.220:443
  • read ETIMEDOUT

Lately this has been happening rarely, say once per month or less, but during the summer I remember it happening much more frequently.

I believe that this is caused by a problem with the connection to Telegram - maybe my Internet connection goes down, or more likely the Telegram servers are having some problems.

The documentation about polling errors says:

An error may occur during polling. It is up to you to handle it as you see fit. You may decide to crash your bot after a maximum number of polling errors occurring. It is all up to you.

This sounds weird to me... node-telegram-bot-api should either keep polling, or close the socket and give up. It seems that instead it keeps the socket alive (thus keeping the event loop alive and preventing my bot from terminating), but stops doing anything with it...

Can anybody else confirm this behavior?

How do you deal with it? The only way is terminating the process as soon as the first polling_error is received? Isn't there any way to know whether node-telegram-bot-api will try to poll again?

peoro avatar Oct 05 '18 17:10 peoro

I can confirm I experience this bug too.

gch1p avatar Feb 07 '21 12:02 gch1p

@gch1p What ISP/Region is your bot hosted on?

kamikazechaser avatar Feb 11 '21 07:02 kamikazechaser