Manage error 429 (too many send)
Hello, I'm using sendasync... But many time mybot got error 429. Can u add a controller to check it and prevent this error? I think you must prevent to send more than 30 message in a second. Sorry for bad english... Tnx
I don't think that this library is the appropriate place for such functionality. It's just a wrapper around HTTP API. There could be a framework around this library and thats where it fits better. Actually soon @pouladpld's framework can be moved to the repo's organization and there we can implement 429 error handling. Though it's just my opinion and the maintainers can have a different one.
@mahdial It might be implemented in v14 of Client. We will check this in coming weeks when Request types are in place.
here is a suggestion:
var req = new SendTextMessageRequest(chatId, "Hello, World!", cancellationToken)
{
RetryCount = 3;
RetryAfter = TimeSpan.FromSeconds(2)
};
try {
await BotClient.MakeRequestAsync(req);
} catch(ApiRequestException e) {
// log
throw;
}
@pouladpld @Tuscen Thank you. I hope to see it in v14. For now, i want to write a code to prevent send more than 29 messages in a second. After that , i will send it here. Tnx
Any update on this feature?
@jcmag We'd probably implement such features in a framework package. For the time being, I'd suggest you using Polly.
I didn't know Polly, it seems very useful, thanks!
@MihaZupan suggested this https://github.com/MihaZupan/TelegramBotClients - Telegram Bot Client with message queue, that prevents hitting rate limit