From 40ec048766115a164abf39337026f48129397394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= <39929354+denizsafak@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:42:41 +0300 Subject: [PATCH] Update HotspotAutoLogin.pyw --- HotspotAutoLogin.pyw | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/HotspotAutoLogin.pyw b/HotspotAutoLogin.pyw index 22b822b..9faaaf0 100644 --- a/HotspotAutoLogin.pyw +++ b/HotspotAutoLogin.pyw @@ -129,7 +129,17 @@ def check_network_status(): save_to_file(message) # Semd the request and ignore SSL errors - response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False) + try: + response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False) + except requests.exceptions.RequestException as e: + # Catch the exception and add a delay before trying again + errorcount += 1 + sleepcount = 10 + message = "Failed to send request: {e}".format(e=e)+" Trying again in "+str(sleepcount)+" seconds... (Errors: "+str(errorcount)+"/10)" + add_to_log(message) + save_to_file(message) + time.sleep(sleepcount) + continue # Check the response status code if response.status_code == 200: