u/EDM115
-
5,321points
EDM115
EDM115
hey, thanks for your reply :)
I'm going to give a detailed follow-up for anyone who faces the same issue and finds this.
A lot of users on Hetzner have issues connecting to telegram servers. all night i looked at messages that states less or more the same thing (connection works but randomly times out frequently under load).
The user Яico X on Telegram summed up most problems :
Slow response times for Telegram bots / Hetzner Servers:
0) Most (but not all) users with that issue are running a server on Hetzner's DCs
1) Routes seem to be stable without packet loss (https://t.me/BotTalk/919740) (apart from one hop not responding to ICMP)
2) ping is stable (https://t.me/BotTalk/919757) at about 13ms
3) Some http requests run into the connect timeout (https://t.me/BotTalk/919790)
4) It seems like some TCP SYN packets don't receive TCP SYN-ACK replies (https://t.me/BotTalk/919825)
His workaround :
Make sure to configure a http connection timeout for your http library. Otherwise your bot will be blocking for whatever the default timeout is (for curl it's 130s, so your bot could be unresponsive for several minutes).
This works when you're directly dealing with the Telegram API (ex https://api.telegram.org/botToken/method), but not when you use MTProto based libraries (like Pyrogram, Telethon and most libraries out there).
From my own tests, the libraries have massive issues connecting and especially maintaining a stable connection. The bot could get updates of events 30 minutes after it happened, even 1 hour after; and (in my case), upload of files would be absurdly low (the library creates a connection, fails 10 times in a row to upload a small chunk of the file, recreates a new connection, repeat...). The average upload speed I was able to achieve was 7 KiB/s... Whereas it should be around 20 MiB/s in normal situation.
The solution ?
Don't use Shared servers !!!
As Katie pointed out, it is most likely a noisy neighbor issue. Too much users abused it and the connection throttles/fails to succeeds. Maybe I was unlucky, but too many other users faced this issue for it to be ignored.
I've been conducting tests on a Dedicated instance, and indeed it already is better :) Max performance and even better than what I had before 💪 Hetzner rocks !
Also if you get to choose, don't pick Finland. Overall internet speed are good there but connection ping to Telegram's DC (EU, US and Asia) are better in Germany.
Using a dedicated server was absolutely NOT in my budget for this month but I guess I had no real other choice. Fortunately some of my users donated to help finance this new server but still that was not planned.
EDM115
Links to Original Quality pictures :
EDM115
Here's the post content (Reddit deleted it) telegra[.]ph/file/b95c8000211556948786f.jpg telegra[.]ph/file/f0afe64602611766aba86.jpg
r/lostredditor ?