Hello, while my program was running, I suddenly got the connection error. How can I check that I have successfully connected to the API?
If the connection is successful, I want it to break the loop, and if there is an error, I want it to try to connect again after 5 seconds.
For this I wrote the following code;
import time
from binance.client import Client
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
But because the client is an object, not a list, the len() function does not work. In addition, even if I leave the api key and api secret values blank, it does not give an error about establishing a connection.