From 55ff7bd325c38438d4bc9848c0b1f513e4369cde Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Mon, 15 Oct 2018 14:12:50 -0700 Subject: [PATCH] fix: ADM handle connection timeout (#134) --- lib/pigeon/adm/worker.ex | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/pigeon/adm/worker.ex b/lib/pigeon/adm/worker.ex index 4828e47a..92354746 100644 --- a/lib/pigeon/adm/worker.ex +++ b/lib/pigeon/adm/worker.ex @@ -155,11 +155,15 @@ defmodule Pigeon.ADM.Worker do _ -> fn {reg_id, payload} -> - {:ok, %HTTPoison.Response{status_code: status, body: body}} = - HTTPoison.post(adm_uri(reg_id), payload, adm_headers(state)) - - notification = %{notification | registration_id: reg_id} - process_response(status, body, notification, on_response) + case HTTPoison.post(adm_uri(reg_id), payload, adm_headers(state)) do + {:ok, %HTTPoison.Response{status_code: status, body: body}} -> + notification = %{notification | registration_id: reg_id} + process_response(status, body, notification, on_response) + + {:error, %HTTPoison.Error{reason: :connect_timeout}} -> + notification = %{notification | response: :timeout} + process_on_response(on_response, notification) + end end end