Unable to Catch ApiRequestException for 429 (Too Many Requests)
See original GitHub issueI found a bug to report
Please use the following template to ensure maintainers can reproduce the bug and solve it quickly.
Bug reports that do not follow this template will be kept closed because not-reproducible until the creator edits the post properly.
Steps to reproduce
try
{
// Send 100 text messages to a group chat
for (int i = 0; i < 100; i++)
await Bot.SendTextMessageAsync(chatId, "Hello");
}
catch (ApiRequestException e)
{
// Retry after the wait time
await Task.Delay(e.Parameters.RetryAfter);
await Bot.SendTextMessageAsync(chatId, "Hello");
}
Expected behavior
I expect to catch ApiRequestException so that I can get the retry_after ResponseParameter.
Actual behavior
HttpRequestException is thrown, which doesn’t include the retry_after ResponseParameter. So I have no way of knowing how long I should wait before retrying.
Screenshots
Screenshot
Environment data
NuGet Package Version: 15.5.1
.NET Version: 4.7.2
IDE: VS2019
App: Console
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (7 by maintainers)
Top Results From Across the Web
How to Fix 429 Too Many Requests Error
The HTTP 429 error is returned when too many requests are made to a page within a short period of time. Find out...
Read more >Telegram bot api: Error code 429, Error: Too many requests
Based on the Telegram Bots FAQ for sending messages, you should consider this: If you're sending bulk notifications to multiple users, the API ......
Read more >What Does HTTP Error 429: Too Many Requests Mean? ...
HTTP Error 429 is an HTTP response status code that indicates the client application has surpassed its rate limit, or number of requests...
Read more >How to Fix 429 Too Many Requests Error Code: 6 Methods
How to Fix the 429 Too Many Requests Error Code · 1. Flush Cache · 2. Check Your Order Usage on hPanel ·...
Read more >429 Error – Too Many Requests HTTP Code Explained
It means that the website can't handle the number of requests being sent to it. For a developer, this error can be hard...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kirsan31 It will be fixed only in the next major release since fixing it is a breaking change in terms of runtime behaviour. You’ll have to wait for it.
this issue is addressed in https://github.com/TelegramBots/Telegram.Bot/commit/bb50b5de3150553bc3dd801d3c4e2e9dc75f4c57