orangecoding / fredy

:heart: Fredy - [F]ind [R]eal [E]states [D]amn Eas[y] - Fredy will constantly search for new listings on sites like Immoscout or Immowelt and send new results to you, so that you can focus on more important things in life ;)
http://www.orange-coding.net
MIT License
231 stars 58 forks source link

Telegram Adapter 'Too Many Requests' #57

Closed daniel17903 closed 2 years ago

daniel17903 commented 2 years ago

Describe the bug I am using fredy the first time and created a new Job using the Telegram Adapter. Initially a lot of listings were found. In the log I see many HTTP 429 Responses like this:

[AxiosError: Request failed with status code 429] {
  code: 'ERR_BAD_REQUEST',
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
...

I think the issue is that there currently is no limit of how many messages are sent. The telegram Bots FAQ says "avoid sending more than one message per second" and "your bot will not be able to send more than 20 messages per minute to the same group" (see https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this).

So I think there should be some delay in between requests to the telegram API and maybe also some kind of retry mechanism if sending a message fails.

orangecoding commented 2 years ago

Thanks, this commit should address the issue: https://github.com/orangecoding/fredy/commit/bc018064218d82bd5c5a1e6338ddd8e4659cf5da