Hello, while my program was running, I suddenly got the error you see below. What is the reason of this?
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "C:\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\Anaconda3\lib\socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Anaconda3\lib\site-packages\urllib3\connection.py", line 353, in connect
conn = self._new_conn()
File "C:\Anaconda3\lib\site-packages\urllib3\connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000001F740E1AD90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/ping (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001F740E1AD90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Yunus/PycharmProjects/kripthon_wb/main.py", line 38, in <module>
client = Client(config.api_key, config.api_secret)
File "C:\Anaconda3\lib\site-packages\binance\client.py", line 300, in __init__
self.ping()
File "C:\Anaconda3\lib\site-packages\binance\client.py", line 526, in ping
return self._get('ping', version=self.PRIVATE_API_VERSION)
File "C:\Anaconda3\lib\site-packages\binance\client.py", line 371, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Anaconda3\lib\site-packages\binance\client.py", line 334, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Anaconda3\lib\site-packages\binance\client.py", line 314, in _request
self.response = getattr(self.session, method)(uri, **kwargs)
File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Anaconda3\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/ping (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001F740E1AD90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
If the line of code that caused the program to fail,
client = Client(config.api_key, config.api_secret)
If the above line is.
while True:
try:
client = Client(config.api_key, config.api_secret)
if len(client ) > 0:
break
except Exception as e:
print("Error:", e)
time.sleep(5)
pass
Would putting it inside a loop like this with try except blocks fix the problem?