Polling errors stalling the bot
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 Gatewayconnect ETIMEDOUT 149.154.167.220:443connect ENETUNREACH 149.154.167.220:443read 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?
I can confirm I experience this bug too.
@gch1p What ISP/Region is your bot hosted on?