Budget: 2500 UAH Deadline: 1 day
Hello! The situation where the bot suddenly stops uploading files while maintaining a stable ping to Telegram servers is most often related to configuration-level limitations of the library or network stack, rather than a physical lack of connectivity. Since the bot has been running for a year, it is likely that the traffic volume has changed or Telegram has updated interaction protocols, leading to timeouts in your current code.
🔍 Possible causes and solutions:
1. Standard client limitations (Timeout settings)
Most libraries (aiogram, telethon, pyrogram) have a default timeout of 10-20 seconds. If the photos have become heavier or the communication channel temporarily dips, the bot drops the connection.
* Fix: You need to explicitly increase the request_timeout in the session or client settings to 60+ seconds.
2. DNS or IPv6 issues
Often, Telegram servers try to connect via IPv6, which may work unstably on hosting. The ping may go through IPv4, so you do not see any issues.
* Fix: Force the bot to operate only through IPv4.
3. Blocking at the Cloudflare/MTU level
If your server is behind certain firewalls, large packets (photos) may be dropped due to incorrect MTU size, while small packets (ping) pass through.
* Fix: Check and configure the server's network interface.
4. Telegram API limitations (Local Bot API Server)
If the bot uploads too much media, the standard Telegram server may impose limits.
* Fix: Switch to your own Telegram Bot API Server (local server), which removes file size and upload speed limitations.
📋 My correction plan:
* Audit PM2 logs and code: I will thoroughly investigate the error (likely a ReadTimeout or ConnectTimeout).
* Network diagnostics: I will check the routing specifically for large requests to api.telegram.org.
* Code adjustments:
* Implement asynchronous chunks for uploads.
* Increase timeout limits in the HTTP client (aiohttp/httpx).
* Add a Retries mechanism (automatic retries on timeout).
* Testing: Check file uploads of various sizes under load.
⏱ Deadlines and cost:
* Execution time: 2–5 hours (I will do it today).
* Cost: 1,500 – 2,500 UAH (depends on whether it is just timeout settings or a problem with the server's network configuration).
Why me:
As a specialist in automation and Telegram API (30+ projects), I have repeatedly encountered similar "phantom" timeouts.