Rongronggg9 / RSS-to-Telegram-Bot

A Telegram RSS bot that cares about your reading experience
https://t.me/RSStT_Bot
GNU Affero General Public License v3.0
1.55k stars 276 forks source link

FloodWaitError #542

Closed HeroadZ closed 1 month ago

HeroadZ commented 1 month ago

Describe the bug

[!TIP]\ A clear and concise description of what the bug is.

only the first command will be executed after restarting.

To Reproduce

[!TIP]\ Steps to reproduce the behavior.

  1. restart the docker container by docker compose up -d
  2. send several /list command in telegram
  3. command after second doesn't have any response

Screenshots

[!TIP]\ If applicable, upload screenshots to help explain your problem.

Feed URL

[!TIP]\ If applicable, provide the feed URL that causes the bug.

Expected behavior

[!TIP]\ A clear and concise description of what you expected to happen.

Important log

[!IMPORTANT]\ Rerun RSStT with DEBUG=1 set in the environment variables, and paste the log below. If you are using Docker, you can get the log by executing:

docker logs <container name>
$ docker logs 75ac51a451a1
2024-09-30-10:59:55:INFO:RSStT.env - Config folder: /app/config
2024-09-30-10:59:56:INFO:RSStT - API_ID and/or API_HASH not set, use sample APIs instead. API_ID_PUBLISHED_FLOOD_ERROR may occur.
2024-09-30-10:59:56:INFO:RSStT.db - Successfully connected to the DB
2024-09-30-10:59:57:INFO:RSStT - RSS-to-Telegram-Bot (v2.9.0-5-g5a67570@dev, build@2024-09-17T15:29:40+00:00) started!
SELF: rss2tg Bot @chance_rss2tg_bot (5694024327)
MANAGER: 880551570
ERROR_LOGGING_CHAT: 880551570
T_PROXY (for Telegram): not set
R_PROXY (for RSS): not set
DATABASE: sqlite:/app/config/db.sqlite3
TELEGRAPH: Disable
UVLOOP: Enable
MULTIUSER: Enable
CPU: 1 (usable) / 1 (available) / 1 (total)
2024-09-30-11:00:01:WARNING:RSStT.locks - Blocking any further messages for 861035684 due to flood control, 19152.00s left
2024-09-30-11:00:01:WARNING:RSStT.locks - Blocking any further messages for 1292505774 due to flood control, 19152.00s left
2024-09-30-11:00:08:INFO:RSStT.command - Allow blink (880551570) to use /export
2024-09-30-11:00:08:INFO:RSStT.command - Exported feed(s) for 880551570
2024-09-30-11:00:15:WARNING:RSStT.locks - Blocking any further messages for 118069398 due to flood control, 19138.00s left
2024-09-30-11:00:15:INFO:RSStT.command - Allow blink (880551570) to use /activate_subs
2024-09-30-11:00:15:ERROR:RSStT.command - Uncaught error occurred when blink (880551570) attempting to use /activate_subs
Traceback (most recent call last):
  File "/app/src/command/utils.py", line 505, in wrapper
    await execute()
  File "/app/src/command/utils.py", line 368, in execute
    await asyncio.wait_for(
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/app/src/command/customization.py", line 284, in cmd_activate_or_deactivate_subs
    await callback_get_activate_or_deactivate_page.__wrapped__(event, activate, lang=lang, chat_id=chat_id, page=1)
  File "/app/src/command/customization.py", line 334, in callback_get_activate_or_deactivate_page
    await (
  File "/opt/venv/lib/python3.12/site-packages/telethon/tl/custom/message.py", line 764, in respond
    return await self._client.send_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/messages.py", line 905, in send_message
    result = await self(request)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/users.py", line 56, in _call
    raise errors.FloodWaitError(request=r, capture=diff)
telethon.errors.rpcerrorlist.FloodWaitError: A wait of 19137 seconds is required (caused by SendMessageRequest)
2024-09-30-11:00:15:WARNING:RSStT.locks - Blocking any further messages for 880551570 due to flood control, 19138.00s left
2024-09-30-11:00:42:WARNING:RSStT.locks - Blocking any further messages for 557382913 due to flood control, 19111.00s left
2024-09-30-11:00:45:WARNING:RSStT.locks - Blocking any further messages for -1001827528289 due to flood control, 19108.00s left
2024-09-30-11:01:12:WARNING:RSStT.locks - Blocking any further messages for -1001862440612 due to flood control, 19081.00s left
2024-09-30-11:01:43:WARNING:RSStT.locks - Blocking any further messages for -1002005713895 due to flood control, 19049.00s left
2024-09-30-11:01:54:WARNING:RSStT.locks - Blocking any further messages for -1001877989123 due to flood control, 19039.00s left
2024-09-30-11:03:26:INFO:RSStT.env - Config folder: /app/config
2024-09-30-11:03:27:INFO:RSStT - API_ID and/or API_HASH not set, use sample APIs instead. API_ID_PUBLISHED_FLOOD_ERROR may occur.
2024-09-30-11:03:27:INFO:RSStT.db - Successfully connected to the DB
2024-09-30-11:03:27:INFO:RSStT - RSS-to-Telegram-Bot (v2.9.0-5-g5a67570@dev, build@2024-09-17T15:29:40+00:00) started!
SELF: rss2tg Bot @chance_rss2tg_bot (5694024327)
MANAGER: 880551570
ERROR_LOGGING_CHAT: 880551570
T_PROXY (for Telegram): not set
R_PROXY (for RSS): not set
DATABASE: sqlite:/app/config/db.sqlite3
TELEGRAPH: Disable
UVLOOP: Enable
MULTIUSER: Enable
CPU: 1 (usable) / 1 (available) / 1 (total)
2024-09-30-11:03:57:INFO:RSStT.command - Allow blink (880551570) to use /list
2024-09-30-11:04:01:WARNING:RSStT.locks - Blocking any further messages for 861035684 due to flood control, 18912.00s left
2024-09-30-11:04:01:WARNING:RSStT.locks - Blocking any further messages for 1292505774 due to flood control, 18912.00s left
2024-09-30-11:04:02:INFO:RSStT.command - Allow blink (880551570) to use /list
2024-09-30-11:04:02:ERROR:RSStT.command - Uncaught error occurred when blink (880551570) attempting to use /list
Traceback (most recent call last):
  File "/app/src/command/utils.py", line 505, in wrapper
    await execute()
  File "/app/src/command/utils.py", line 368, in execute
    await asyncio.wait_for(
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/app/src/command/sub.py", line 204, in cmd_list_or_callback_get_list_page
    await (
  File "/opt/venv/lib/python3.12/site-packages/telethon/tl/custom/message.py", line 764, in respond
    return await self._client.send_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/messages.py", line 905, in send_message
    result = await self(request)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/telethon/client/users.py", line 56, in _call
    raise errors.FloodWaitError(request=r, capture=diff)
telethon.errors.rpcerrorlist.FloodWaitError: A wait of 18910 seconds is required (caused by SendMessageRequest)
2024-09-30-11:04:02:WARNING:RSStT.locks - Blocking any further messages for 880551570 due to flood control, 18911.00s left
2024-09-30-11:04:09:WARNING:RSStT.locks - Blocking any further messages for 118069398 due to flood control, 18904.00s left
2024-09-30-11:04:19:WARNING:RSStT.locks - Blocking any further messages for -1001862440612 due to flood control, 18894.00s left
2024-09-30-11:04:26:WARNING:RSStT.locks - Blocking any further messages for -1001827528289 due to flood control, 18887.00s left
2024-09-30-11:04:32:WARNING:RSStT.locks - Blocking any further messages for 557382913 due to flood control, 18881.00s left
2024-09-30-11:04:52:WARNING:RSStT.locks - Blocking any further messages for -1001877989123 due to flood control, 18862.00s left
2024-09-30-11:06:27:WARNING:RSStT.locks - Blocking any further messages for 1754919950 due to flood control, 18766.00s left
Rongronggg9 commented 1 month ago

Messages from bots have a very low priority on the server side of Telegram (i.e. Telegram DCs). When a Telegram DC is under high server loads ("service degradation"), bot messages are dropped severely. As a result, the DC asks bots not to send more messages by returning FloodWaitError with an absurd delay.

We can do nothing but wait for the DC to recover from the service degradation.

~Currently, DC5 is under service degradation and @RSStT_Bot is also suffering from the same error.~ Your bot also seems to belong to DC5.

HeroadZ commented 1 month ago

Thank you for detailed response!

Is it possible to solve this problem by recreating a bot of other DC(seems like assigned randomly)? This problem has existed for at least half year, I don't think it will be solved recently lol

Rongronggg9 commented 1 month ago

Is it possible to solve this problem by recreating a bot of other DC(seems like assigned randomly)?

AFAIK, a bot is created at the same DC as its creator, i.e., if your Telegram account belongs to DC5, all your bots will belong to DC5 too.

This problem has existed for at least half year, I don't think it will be solved recently lol

It has existed for several years. Generally, a service degradation will be resolved within a day, and @RSStT_Bot works all fine now.

HeroadZ commented 1 month ago

Generally, a service degradation will be resolved within a day

But my bot won't respond to any command forever once the error occurred. What do I need to do to make sure it will be recovered?

Rongronggg9 commented 1 month ago

What do I need to do to make sure it will be recovered?

Once the service degradation comes to an end, restart the bot.

HeroadZ commented 1 month ago

restart the bot

Could you tell me the detailed steps to restart the bot? Do you mean restarting the docker container? Or restarting the telegram bot by some command within Telegram client?

Rongronggg9 commented 1 month ago

restart RSStT, i.e., restart the docker container if it is deployed via docker.