LonamiWebs / Telethon

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

ConnectionError: Cannot send requests while disconnected #1144

Closed StanislavTomilov closed 5 years ago

StanislavTomilov commented 5 years ago

Hi, I'am trying to test connection by using Telethon. Copy a code from "README.rst" (https://github.com/LonamiWebs/Telethon). I have this code in my module:


from telethon import TelegramClient, events, sync
api_id = 123
api_hash = '0123'
client = TelegramClient('session_name', api_id, api_hash)
client.start
print(client.get_me().stringify())```
After I have run it, got this issue:
RESTART: C:/Users/Xiaomi/AppData/Local/Programs/Python/Python37/TelegramConnectionTest.py
Traceback (most recent call last):
File "C:/Users/Xiaomi/AppData/Local/Programs/Python/Python37/TelegramConnectionTest.py", line 6, in 
print(client.get_me().stringify())
File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\sync.py", line 35, in syncified
return loop.run_until_complete(coro)
File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 584, in run_until_complete
return future.result()
File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\client\users.py", line 117, in get_me
functions.users.GetUsersRequest([types.InputUserSelf()])))[0]
File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\client\users.py", line 40, in call
future = self._sender.send(request, ordered=ordered)
File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\network\mtprotosender.py", line 177, in send
raise ConnectionError('Cannot send requests while disconnected')
ConnectionError: Cannot send requests while disconnected
Lonami commented 5 years ago

And here I thought you fixed it in #1443 and that's why you closed it… 🤦‍