Skip to content

Socket error - timed out for ipv6 proxy #322

@Lerbytech

Description

@Lerbytech

I use my own private proxy and trying to connect my client to proxy.
Proxy is valid. Tg account is also ok - I can see messages if try to connect without proxy.
When I try to connect I get socket timed out exception. I am new to python, so perhaps I am doing something wrong.

I've seen several issues about ipv6 proxy support, but as far as i understand it was implemented successfully. I checked sources and see that logic for ipv6 is included.
Based on issues I've imported pysocks lib to cast proxy field (is it valid?), so my code is below:
Code:
clientP = TelegramClient(phone_number, api_id, api_hash, proxy=(socks.SOCKS5, '5.188.215.240', 5574, 1, login, pass), timeout=timedelta(seconds=3))

clientP.connect()

Still I get exception
I'll appreciate any help although I understand that problem might be quite obvious.
Thanks in advance.

Stacktrace:

Unable to display children:Error resolving variables Traceback (most recent call last):
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 813, in connect
negotiate(self, dest_addr, dest_port)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 477, in _negotiate_SOCKS5
CONNECT, dest_addr)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 503, in _SOCKS5_request
chosen_auth = self._readall(reader, 2)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 304, in _readall
d = file.read(count - len(data))
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Little-Dany/PycharmProjects/TG2/main2.py", line 265, in test
clientP.connect();
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telethon\telegram_bare_client.py", line 187, in connect
self._sender.connect()
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telethon\network\mtproto_sender.py", line 46, in connect
self.connection.connect(self.session.server_address, self.session.port)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telethon\network\connection.py", line 79, in connect
self.conn.connect(ip, port)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telethon\extensions\tcp_client.py", line 49, in connect
self._socket.connect(address)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 96, in wrapper
return function(*args, **kwargs)
File "C:\Users\Little-Dany\AppData\Local\Programs\Python\Python36-32\lib\site-packages\socks.py", line 817, in connect
raise GeneralProxyError("Socket error", error)
socks.GeneralProxyError: Socket error: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev_pydevd_bundle\pydevd_resolver.py", line 238, in resolve
return dict[key]
KeyError: 'Exception'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev_pydevd_bundle\pydevd_comm.py", line 1004, in do_it
_typeName, valDict = pydevd_vars.resolve_compound_variable(self.thread_id, self.frame_id, self.scope, self.attributes)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev_pydevd_bundle\pydevd_vars.py", line 246, in resolve_compound_variable
var = getVariable(thread_id, frame_id, scope, attrs)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev_pydevd_bundle\pydevd_vars.py", line 238, in getVariable
var = resolver.resolve(var, k)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev_pydevd_bundle\pydevd_resolver.py", line 240, in resolve
return getattr(dict, key)
AttributeError: 'dict' object has no attribute 'Exception'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions