From 79fb1a54cb176993835ee0e83bb5af24722f8f7c Mon Sep 17 00:00:00 2001 From: ov7a Date: Sun, 12 Apr 2020 15:28:40 +0300 Subject: [PATCH] Switch to blocking connect when using proxy (#1432) Until a better fix is found, this should help proxy users. --- telethon/network/connection/connection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telethon/network/connection/connection.py b/telethon/network/connection/connection.py index d7190c73..d6b9ea16 100644 --- a/telethon/network/connection/connection.py +++ b/telethon/network/connection/connection.py @@ -65,7 +65,7 @@ class Connection(abc.ABC): else: s.set_proxy(*self._proxy) - s.setblocking(False) + s.settimeout(timeout) await asyncio.wait_for( self._loop.sock_connect(s, address), timeout=timeout, @@ -78,14 +78,14 @@ class Connection(abc.ABC): 'without the SSL module being available' ) - s.settimeout(timeout) s = ssl_mod.wrap_socket( s, do_handshake_on_connect=True, ssl_version=ssl_mod.PROTOCOL_SSLv23, ciphers='ADH-AES256-SHA' ) - s.setblocking(False) + + s.setblocking(False) self._reader, self._writer = \ await asyncio.open_connection(sock=s, loop=self._loop)