Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot api: Error code 429, Error: Too many requests: retry later

We have a Telegram bot. It has around 1.2 million subscribers.

Now we're facing a problem in sending messages to these number of subscribers.

Telegram bot API does not provide any batch message functionality and we'd have to send individual requests to Telegram. The problem is, after a few thousand messages, Telegram starts responding with Error 429: too many requests, and does not accept any requests for a while.

How can we effectively message our subscribers?

like image 897
Pooya Saberian Avatar asked Aug 10 '15 07:08

Pooya Saberian


People also ask

What does Error 429 too many requests mean?

The HTTP 429 Too Many Requests response status code indicates the user has sent too many requests in a given amount of time ("rate limiting").

How many requests can a telegram BOT handle?

Telegram API Performance Limitations Currently, Telegram is limited to sending a maximum of 100 requests per second to your backend. The sooner you are able to process this request and reply, the sooner users will see the changes in the bot client.

When you get 429 response code what should you do next?

Wait to send another request. The simplest way to fix an HTTP 429 error is to wait to send another request. Often, this status code is sent with a “Retry-after” header that specifies a period of time to wait before sending another request. It may specify only a few seconds or minutes.


2 Answers

You should simply implement a global rate limiter to ensure no single user gets above a fixed number of messages per second. to be safe, set your limiter at lower than 30, maybe even to 5 msgs per second.

Really anything higher than 5 messages per second to a single user quickly becomes an annoyance.

cheers.

like image 100
Charles Okwuagwu Avatar answered Sep 19 '22 00:09

Charles Okwuagwu


I'm the owner of Ramona Bot. There is a limit for sending message to users. as they said ~30 message per second. Otherwise you will get that Error 429.

like image 42
user3313781 Avatar answered Sep 21 '22 00:09

user3313781