Telethon icon indicating copy to clipboard operation
Telethon copied to clipboard

Global proxy issue

Open M1KTA-OFF opened this issue 1 year ago • 1 comments

Checklist

  • [ ✓] The error is in the library's code, and not in my own.
  • [ ✓] I have searched for this issue before posting it and there isn't a duplicate.
  • [ ✓] I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip and triggered the bug in the latest version.

This is very strange bug, this scripts working correctly on my windows PC, but when i load it on linux server happens this bug. How can i fix it?

Code that causes the issue

import socks
from telethon import TelegramClient
from opentele.api import API

api = API.TelegramDesktop()
proxy = (socks.SOCKS5, "****", "****", True, "****", "*****")
client = TelegramClient("test", api_id=api.api_id, api_hash=api.api_hash, proxy=proxy)
async def main():
    await client.connect()
client.loop.run_until_complete(main())
client.disconnect()

Traceback

Traceback (most recent call last):
  File "/root/LoginTest/main.py", line 14, in <module>
    client.loop.run_until_complete(main())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/root/LoginTest/main.py", line 11, in main
    await client.connect()
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/telegrambaseclient.py", line 525, in connect
    if not await self._sender.connect(self._connection(
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/mtprotosender.py", line 127, in connect
    await self._connect()
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/mtprotosender.py", line 227, in _connect
    connected = await self._try_connect(attempt)
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/mtprotosender.py", line 277, in _try_connect
    await self._connection.connect(timeout=self._connect_timeout)
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/connection/connection.py", line 244, in connect
    await self._connect(timeout=timeout, ssl=ssl)
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/connection/connection.py", line 225, in _connect
    sock = await self._proxy_connect(
  File "/usr/local/lib/python3.10/dist-packages/telethon/network/connection/connection.py", line 192, in _proxy_connect
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 499, in sock_connect
    return await fut
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 504, in _sock_connect
    sock.connect(address)
  File "/usr/local/lib/python3.10/dist-packages/socks.py", line 47, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/socks.py", line 787, in connect
    super(socksocket, self).connect(proxy_addr)
TypeError: 'str' object cannot be interpreted as an integer

M1KTA-OFF avatar Jul 28 '22 15:07 M1KTA-OFF

Your proxy port should be an integer, not a string

neon-ninja avatar Aug 03 '22 01:08 neon-ninja

Closing under the assumption it's a problem with user-code and not related to Telethon (as the previous commenter mentioned). Thanks.

Lonami avatar Sep 20 '22 11:09 Lonami