This commit is contained in:
Matthew Frost 2023-11-01 00:11:00 +01:00
parent 438587e260
commit 9ed547c701

View file

@ -26,7 +26,7 @@ HEADERS = {
}
# Define a maximum number of retry attempts and a delay between retries
MAX_RETRY_ATTEMPTS = 3
MAX_RETRY_ATTEMPTS = 5 # Changed to 5
RETRY_DELAY_SECONDS = 10
def handle_log_msg(prefix, value):
@ -45,6 +45,10 @@ def send_http_request_with_retry(url, data, headers):
elif reader_info.get("mode") == "TOGGLE":
ser.write("toggle".encode('utf-8'))
break # Successful request, no need to retry
elif response.status_code in [400, 401, 500]:
# Don't retry on certain errors
print(f"HTTP POST request failed with status code {response.status_code}. Not retrying.")
break
else:
print(f"Failed to send FULL_CARD_ID via HTTP POST. Status code: {response.status_code}")
print(response.text)