mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 04:30:22 +03:00
proxy connection fix #2
This commit is contained in:
parent
9e08d5b735
commit
937523419d
|
@ -9,6 +9,11 @@ from datetime import timedelta
|
|||
from io import BytesIO, BufferedWriter
|
||||
from threading import Lock
|
||||
|
||||
try:
|
||||
import socks
|
||||
except ImportError:
|
||||
socks = None
|
||||
|
||||
MAX_TIMEOUT = 15 # in seconds
|
||||
CONN_RESET_ERRNOS = {
|
||||
errno.EBADF, errno.ENOTSOCK, errno.ENETUNREACH,
|
||||
|
@ -70,9 +75,10 @@ class TcpClient:
|
|||
|
||||
self._socket.connect(address)
|
||||
break # Successful connection, stop retrying to connect
|
||||
except ProxyConnectionError:
|
||||
raise
|
||||
except OSError as e:
|
||||
# Stop retrying to connect if proxy connection error occurred
|
||||
if socks and isinstance(e, socks.ProxyConnectionError):
|
||||
raise
|
||||
# There are some errors that we know how to handle, and
|
||||
# the loop will allow us to retry
|
||||
if e.errno in (errno.EBADF, errno.ENOTSOCK, errno.EINVAL,
|
||||
|
|
Loading…
Reference in New Issue
Block a user