LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.72k stars 1.39k forks source link

Wrong Session ID and Unsuccesful Attempts #4081

Closed ArslanKAS closed 1 year ago

ArslanKAS commented 1 year ago

Checklist

Code that causes the issue

from telethon.sync import TelegramClient
    async def fetch_contacts(self):
        async with TelegramClient(self.session, self.api_id, self.api_hash) as client:
            # Fetch all the contacts
            contacts = await client(GetContactsRequest(hash=0))
            # Store the contacts in a data frame
            df = pd.DataFrame([{'Username': c.username or '', 'Name': c.first_name + ' ' +
                                c.last_name if c.last_name else c.first_name, 'Phone': c.phone, 'UserID': int(c.id)} for c in contacts.users])
        return df

What I've tried so far:

  1. I've searched for this issue and yes there are duplicates but none of the suggestions worked.
  2. I tried using Proxy but still the problem remains the same
  3. It works on Google Colab for some reason but not at local system
  4. Disabled Firewall and Antivirus but still the same error
  5. Used various suggestion by ChatGPT but none works
  6. Messed around with asyncio but no luck

Traceback

Traceback (most recent call last):
Security error while unpacking a received message: Server replied with a wrong session ID
Security error while unpacking a received message: Server replied with a wrong session ID
Traceback (most recent call last):
  File "c:\Users\HAIER\Desktop\Contact List Scraper\Python_Files\Telegram_Contacts.py", line 300, in on_contacts_radio_checked
    asyncio.run(self.run_main())
  File "C:\Users\HAIER\miniconda3\envs\experiments\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\HAIER\miniconda3\envs\experiments\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "c:\Users\HAIER\Desktop\Contact List Scraper\Python_Files\Telegram_Contacts.py", line 304, in run_main
    await self.main_function()
  File "c:\Users\HAIER\Desktop\Contact List Scraper\Python_Files\Telegram_Contacts.py", line 312, in main_function
    main_contacts = await self.fetch_contacts()
  File "c:\Users\HAIER\Desktop\Contact List Scraper\Python_Files\Telegram_Contacts.py", line 292, in fetch_contacts
    contacts = await client(GetContactsRequest(hash=0))
  File "C:\Users\HAIER\miniconda3\envs\experiments\lib\site-packages\telethon\client\users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "C:\Users\HAIER\miniconda3\envs\experiments\lib\site-packages\telethon\client\users.py", line 130, in _call
    raise ValueError('Request was unsuccessful {} time(s)'
ValueError: Request was unsuccessful 6 time(s)
Lonami commented 1 year ago

Thanks for the detailed issue. Unfortunately this is unlikely to be something Telethon can fix (What does "Server replied with a wrong session ID" mean? in the FAQ). I will close it in favor of #3759.