fix(webhook): treat `{shutdown, normal}` and `{closed, _}` async reply as retriable
Apparently, the async reply returned by ehttpc can be `{shutdown, normal}` or `{closed, "The connection was lost."}`, in which case the request should be retried. ``` Apr 28 17:40:41 emqx-0.int.thales bash[48880]: 17:40:41.803 [error] [id: "bridge:webhook:webhook", msg: :unrecoverable_error, reason: {:shutdown, :normal}] Apr 28 18:36:37 emqx-0.int.thales bash[53368]: 18:36:37.605 [error] [id: "bridge:webhook:webhook", msg: :unrecoverable_error, reason: {:closed, 'The connection was lost.'}] ```
This commit is contained in:
parent
edb39bfec1
commit
a19621e533
|
@ -306,7 +306,20 @@ on_query(
|
|||
Retry
|
||||
)
|
||||
of
|
||||
{error, Reason} when Reason =:= econnrefused; Reason =:= timeout ->
|
||||
{error, Reason} when
|
||||
Reason =:= econnrefused;
|
||||
Reason =:= timeout;
|
||||
Reason =:= {shutdown, normal};
|
||||
Reason =:= {shutdown, closed}
|
||||
->
|
||||
?SLOG(warning, #{
|
||||
msg => "http_connector_do_request_failed",
|
||||
reason => Reason,
|
||||
connector => InstId
|
||||
}),
|
||||
{error, {recoverable_error, Reason}};
|
||||
{error, {closed, _Message} = Reason} ->
|
||||
%% _Message = "The connection was lost."
|
||||
?SLOG(warning, #{
|
||||
msg => "http_connector_do_request_failed",
|
||||
reason => Reason,
|
||||
|
@ -568,7 +581,16 @@ reply_delegator(ReplyFunAndArgs, Result) ->
|
|||
case Result of
|
||||
%% The normal reason happens when the HTTP connection times out before
|
||||
%% the request has been fully processed
|
||||
{error, Reason} when Reason =:= econnrefused; Reason =:= timeout; Reason =:= normal ->
|
||||
{error, Reason} when
|
||||
Reason =:= econnrefused;
|
||||
Reason =:= timeout;
|
||||
Reason =:= normal;
|
||||
Reason =:= {shutdown, normal}
|
||||
->
|
||||
Result1 = {error, {recoverable_error, Reason}},
|
||||
emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result1);
|
||||
{error, {closed, _Message} = Reason} ->
|
||||
%% _Message = "The connection was lost."
|
||||
Result1 = {error, {recoverable_error, Reason}},
|
||||
emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result1);
|
||||
_ ->
|
||||
|
|
Loading…
Reference in New Issue