LonamiWebs / Telethon

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

Faild to connect #4152

Closed mrafieefard closed 1 year ago

mrafieefard commented 1 year ago

Code that causes the issue

` from telethon import TelegramClient, events, sync import socks

api_id = - api_hash = '-'

client = TelegramClient('Crawl', api_id, api_hash)

print(client.get_me())

client.start()`

Expected behavior

I trying to use telethon but I don't know why but It can't connect

Actual behavior

Nothing I just trying to run a telephon

Traceback


  File "/root/TelegramCrawl/main.py", line 9, in <module>
    print(client.get_me())
  File "/usr/local/lib/python3.10/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 159, in get_me
    me = (await self(
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 63, in _call
    future = sender.send(request, ordered=ordered)
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/mtprotosender.py", line 177, in send
    raise ConnectionError('Cannot send requests while disconnected')
ConnectionError: Cannot send requests while disconnected```

### Telethon version

1.28.5

### Python version

3.10.9

### Operating system (including distribution name and version)

Ubuntu 22

### Other details

_No response_

### Checklist

- [X] The error is in the library's code, and not in my own.
- [X] I have searched for this issue before posting it and there isn't an open duplicate.
- [X] I ran `pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip` and triggered the bug in the latest version.
Lonami commented 1 year ago

You have to start the client before using it.

mrafieefard commented 1 year ago

Bro thanks really