EverythingSuckz / TG-FileStreamBot

A telegram bot that will give instant stream links for telegram files without the need of waiting till the download completes.
GNU Affero General Public License v3.0
1.26k stars 1.27k forks source link

auth.ExportAuthorization Floodwait #108

Open pdisk opened 1 year ago

pdisk commented 1 year ago

is this error cuz bot gets restarted every time it reaches 900 mb ram usage (takes only abt 3 minute) or cuz when bot gets restarted all files need to fetched from telegram again? or any other reason

i made the code use session file to persist session even when bot is restarted idk what the issue is please let me know whats causing this or how to fix this

(idk how to write a proper issue sorry 🤓)

EverythingSuckz commented 1 year ago

@pdisk This error might be due to too many users using your server, I highly advice you to use multi client feature to reduce the load of the server. And about the RAM usage, Try setting the USE_SESSION_FILE var to True to use a storage file rather than saving the session files in memory which consumes more RAM. If you still have issues, please attach the logs as a pastebin link next time.

pdisk commented 1 year ago

@EverythingSuckz Yes I already use it with multi_client mode with 10 bots in total and USE_SESSION_FILE var Has Already been set to True, i think it should work without this error if the program isn't restarting cuz of ram usage when the program restarts even with session file the bots are made to get all media session again at once which may be the reason for this floodwait (just my assumption). If that was the case then shouldn't the bot be taking the media sessions from session file instead of getting new fresh ones all at once?

Error: https://pastebin.com/Nw8PJECf

EverythingSuckz commented 1 year ago

@EverythingSuckz Yes I already use it with multi_client mode with 10 bots in total and USE_SESSION_FILE var Has Already been set to True, i think it should work without this error if the program isn't restarting cuz of ram usage when the program restarts even with session file the bots are made to get all media session again at once which may be the reason for this floodwait (just my assumption). If that was the case then shouldn't the bot be taking the media sessions from session file instead of getting new fresh ones all at once?

Error: https://pastebin.com/Nw8PJECf

Not sure about the fact whether pyrogram tried to get media sessions on startup. Like, there are only 5 Telegram DC IDs and we only need 5 media sessions per bot. I don't really understand why Telegram gives floodwait for that even tho media session is being cached and even if it's not cached, it only makes like 5 request at max. Looks like I need to check this issue. Also about the ram usages, normally it won't take much ram when you use a session file btw. Seems like there might be something that's eating up the memory.

HydroHax commented 1 year ago

😶

pdisk commented 1 year ago

@EverythingSuckz This error doesn't stop the program and instead the error is shown every time a file is taken, are there any work around u can suggest to temporarily solve the issue

or if any suggestions to pin point the error, I'll send more logs and findings

(i had to modify the code to take files from multiple channels by passing the channel id along with messageid and had to remove the hash checking part for it) still i don't think that can cause this FloodWait

EverythingSuckz commented 1 year ago

@EverythingSuckz This error doesn't stop the program and instead the error is shown every time a file is taken, are there any work around u can suggest to temporarily solve the issue

or if any suggestions to pin point the error, I'll send more logs and findings

(i had to modify the code to take files from multiple channels by passing the channel id along with messageid and had to remove the hash checking part for it) still i don't think that can cause this FloodWait

So you've modified it? Well then I can't really make sure about the bug since I've hosted the bot with 20 clients and there were no such issues. Maybe provide more logs?

pdisk commented 1 year ago

i fixed the issue with asyncio.Lock()

when server was restarted all the request came at once making the script to generate_media_session multiple times before checking if the function has already been executed with a lock for each bot and each dcid i was able to solve the issue

pdisk commented 1 year ago

@EverythingSuckz i Still Couldn't Figure out what's causing the intense ram usage tho with 10 bots each with work load of 15 (150 in total) at maximux load the ram usage goes up like there is no tomorrow its not an issue with my modification as i only changed the part of url to get chatid with messageid

no other variables or functions has been written as mod

without even a single error the ram usage spike to 1.2 or more if i allow it to

EverythingSuckz commented 1 year ago

i fixed the issue with asyncio.Lock()

when server was restarted all the request came at once making the script to generate_media_session multiple times before checking if the function has already been executed with a lock for each bot and each dcid i was able to solve the issue

Oh, if you think it's a major issue, then feel free to do a PR.

EverythingSuckz commented 1 year ago

@EverythingSuckz i Still Couldn't Figure out what's causing the intense ram usage tho with 10 bots each with work load of 15 (150 in total) at maximux load the ram usage goes up like there is no tomorrow its not an issue with my modification as i only changed the part of url to get chatid with messageid

no other variables or functions has been written as mod

without even a single error the ram usage spike to 1.2 or more if i allow it to

Seems like I'll have to profile the memory usage and see where exactly is this memory is being used.

EverythingSuckz commented 1 year ago

@EverythingSuckz i Still Couldn't Figure out what's causing the intense ram usage tho with 10 bots each with work load of 15 (150 in total) at maximux load the ram usage goes up like there is no tomorrow its not an issue with my modification as i only changed the part of url to get chatid with messageid

no other variables or functions has been written as mod

without even a single error the ram usage spike to 1.2 or more if i allow it to

Seems like I'll have to profile the memory usage and see where exactly is this memory is being used.