can't connect by using proxy
StanislavTomilov opened this issue · 3 comments
Hello, I have tried to connect by using proxy:
client = TelegramClient('anon', api_id, api_hash, proxy=(socks.SOCKS5, '138.68.165.154', 1080))
async def main():
# Getting information about yourself
me = await client.get_me()
# "me" is an User object. You can pretty-print
# any Telegram object with the "stringify" method:
print(me.stringify())
with client:
client.loop.run_until_complete(main())
got this result:
Traceback (most recent call last):
File "C:/Users/Xiaomi/PycharmProjects/TelegramTrader/TTApp/Tests.py", line 28, in
with client:
File "C:\Users\Xiaomi\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\helpers.py", line 122, in _sync_enter
return loop.run_until_complete(self.aenter())
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\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\client\auth.py", line 635, in aenter
return await self.start()
File "C:\Users\Xiaomi\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\client\auth.py", line 139, in _start
await self.connect()
File "C:\Users\Xiaomi\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\client\telegrambaseclient.py", line 414, in connect
proxy=self._proxy
File "C:\Users\Xiaomi\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\network\mtprotosender.py", line 124, in connect
await self._connect()
File "C:\Users\Xiaomi\PycharmProjects\TelegramTrader\venv\lib\site-packages\telethon\network\mtprotosender.py", line 211, in _connect
raise ConnectionError('Connection to Telegram failed %d time(s)', attempt)
ConnectionError: [Errno Connection to Telegram failed %d time(s)] 6
checked proxy, it works:
resp = requests.get('https://www.google.com/', proxies=dict(http='http://138.68.173.29:1080'))
print(resp)
what i'm doing wrong?
Proxy type
Proxy type
socks5, I've tried socks4 (same error) and http(didn't get an answer) too