From b8b58b14a4bfd42aa7ac2968b30cd88279181165 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 9 Apr 2024 11:50:44 -0400 Subject: [PATCH] Throttle retrying when APNS connection closed --- lib/tusker_push/apns.ex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tusker_push/apns.ex b/lib/tusker_push/apns.ex index 78ac1a3..2fbb172 100644 --- a/lib/tusker_push/apns.ex +++ b/lib/tusker_push/apns.ex @@ -11,15 +11,18 @@ defmodule TuskerPush.Apns do handle_response(resp, registration, payload) else {:error, %Finch.Error{reason: :connection_closed}} -> - Logger.warning("Apns Finch connection_closed, retrying") + Logger.warning("Apns Finch connection_closed, retrying in 1s") + Process.sleep(1000) __MODULE__.send(registration, payload) {:error, %Finch.Error{reason: :disconnected}} -> - Logger.warning("Apns Finch disconnected, retrying") + Logger.warning("Apns Finch disconnected, retrying in 1s") + Process.sleep(1000) __MODULE__.send(registration, payload) {:error, %Mint.TransportError{reason: :closed}} -> - Logger.warning("Apns Mint transport closed, retrying") + Logger.warning("Apns Mint transport closed, retrying in 1s") + Process.sleep(1000) __MODULE__.send(registration, payload) {:error, reason} ->