Telegram sendMessage too slow for certain bot
Asked Answered
V

2

7

I have two telegram bots and last time I have noticed, that 2nd bot became to slow.

My research shows that sendMessage call has different time for two of them.

curl "https://api.telegram.org/bot123456789:AAAAAAAAABBBBBBBBCCCCCCC/sendMessage?chat_id=987654321&text=HI"

Here is output for the two different bots:

Call to the first one (fast)

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   224  100   224    0     0    491      0 --:--:-- --:--:-- --:--:--   492

Call to the second bot (slow)

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   227  100   227    0     0     43      0  0:00:05  0:00:05 --:--:--    59

The first sendMessage runs instantly.

For second comes with a Time spend = 5 seconds !!

And its always 2-6 seconds. Does anyone know the reason?

Vicissitude answered 22/6, 2018 at 11:58 Comment(2)
I had same issue on my Telegram bot. Something bot experience infinite loop and it cause delay in sending messages.Dialectal
I have the same issue. Have you solved your problem?Wakerife
U
1

If both of your bots are hosted on the same place then we can exclude networking/routing issue.

What kind are those sendMessage calls? Bulk messages? If you attempted sending the same batch through both of your bots to same set of chat IDs then keep in mind that requests to users that didn't start the chat with the bot will be instantly denied.

Something I noticed in the past is that hitting API limits can cause slowdowns like this, are your bots popular or doing a lot of requests to the API?

Per documentation:

When sending messages inside a particular chat, avoid sending more than one message per second.

If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so (..)

(..) your bot will not be able to send more than 20 messages per minute to the same group

Udela answered 26/6, 2018 at 10:39 Comment(1)
Thank you for answer. No matter where they hosted. It reproducible on my local PC as well as in bots hosting. I just execute single sendMessage api-call with my own chat_id. And response is always normal: {"ok":true... But responce time differs so much for two bot tokens.Vicissitude
F
1

try curl -v ..... to see if those slow requests went through ipv6. I've experienced a similar issue, and found out all ipv4 requests to telegram api sever work fine, but some ipv6 calls took long time to wait.

lf that's the cause of the problem you met, just limit your server to ipv4 only.

Fluviomarine answered 1/7, 2018 at 12:3 Comment(1)
Thank you for answer. I will take it into account. But it's not my case. I'll just duplicate my prev comment: No matter where bots hosted. It reproducible on my local PC as well as in bots hosting. I just execute single sendMessage api-call with my own chat_id. And response is always normal: {"ok":true... But responce time differs so much for two bot tokens.Vicissitude

© 2022 - 2024 — McMap. All rights reserved.