Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[420 FLOOD_WAIT_X] #100

Open
3 tasks done
batreller opened this issue Oct 27, 2024 · 2 comments
Open
3 tasks done

[420 FLOOD_WAIT_X] #100

batreller opened this issue Oct 27, 2024 · 2 comments

Comments

@batreller
Copy link

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

Telegram says: [420 FLOOD_WAIT_X] - A wait of 78 seconds is required (caused by "contacts.ResolveUsername")

here is my code that causes the error

peer = await client.resolve_peer('username')

seems like the problem is caused because I am resolving peer by getting full user by his username instead of just getting it by user_id and access_hash, however, after checking .session file I noticed that there is no peers stored at all. I opened it as SQLite database and opened peers table. It is completely empty.
Is it problem on my side or am I doing anything wrong? Why pyrogram does not cache user_id, access_hash and other fields so I could just get user from cache instead of resolving user by username every time

Steps to reproduce

  1. Call .resolve_peer('username') method a few times

Code example

No response

Logs

No response

@0xWEBMILK
Copy link

Hello! This is a standard delay that is triggered when doing the same thing (or multiple actions) many times in a short period of time.
You can learn more in MTProto documentation: https://core.telegram.org/mtproto

@batreller
Copy link
Author

Hi, in my message I specified that it is caused by not caching user_id and access_hash in .session file which is the reason it resolves username every time instead of getting it by user_id + access_hash

if you add

async for _ in self.tg_client.get_dialogs():
     pass

await self.tg_client.storage.save()

after connecting to the session it will fix the bug and cache everything in .session file

however, it is strange that pyrogram doesn't do that be default as I don't get this issue with telethon (telethon caches everything without problems)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants