rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.63k stars 1.17k forks source link

TelegramApiErrorResponseException: null while GetUpdates Request #1401

Open bratinghosh opened 1 month ago

bratinghosh commented 1 month ago

Describe the bug I have been noticing TelegramApiErrorResponseException if I leave the long polling bot running for couple of days without any updates.

Surprisingly, if i restart the application, the error goes away. Any idea if this is a persistent issue?

To Reproduce Starting the long polling bot application and leave it running for couple of days without activity.

Expected behavior The bot is expected to receive 0 updates without any exception as no new updates are created during that period.

Screenshots Screenshot 2024-07-08 at 3 18 37 PM roblem.

aNNiMON commented 1 month ago

The problem on Telegram servers end, or with the network when reaching them. Here's mine logs:

2024-06-14 04:11:24.694 [pool-3-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 647 millis...
2024-06-16 04:11:22.187 [pool-5-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 327 millis...
2024-06-17 02:28:18.716 [pool-7-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 655 millis...
2024-06-17 02:45:52.528 [pool-7-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 463 millis...
2024-06-25 04:10:43.180 [pool-3-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 726 millis...
2024-06-26 04:10:15.938 [pool-7-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 579 millis...
2024-07-01 04:46:14.304 [pool-7-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 694 millis...
2024-07-07 02:08:43.632 [pool-7-thread-1] ERROR org.telegram.telegrambots.longpolling.BotSession - Error received from Telegram GetUpdates Request, retrying in 451 millis...
bratinghosh commented 1 month ago

I do receive the occasional Exceptions and then resets to usual behaviour. But for the case posted above, it is quite peculiar as it reaches the backoff limit of 90000 millis and any getUpdate after always leads to an Exception. But if backoff limit is not reached, most of the time the retries reset to normal behaviour without exception.

The only way I have managed to reproduce this issue is to keep the bot idle and not give it any updates for several days (1 week to be safe).

aNNiMON commented 1 month ago

@brating actually, I've never reached such timeouts. Sometimes Telegram servers are not available for 2-4 minutes, the maximum is 12830 according to my logs. I also tried to reproduce with maximum timeout, but after that the updates are received as well.

I guess it's something on your end. Possibly network configuration. Also try to update the library to the latest version and/or enable debug logs for a week and check them later.