Skip to content

Commit

Permalink
fix(reconnect): keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Nov 17, 2023
1 parent 4e1533b commit 1dce9bc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/emqtt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,19 @@ connected(info, {timeout, TRef, keepalive},
true ->
case send(?PACKET(?PINGREQ), State) of
{ok, NewState} ->
{ok, [{send_oct, Val}]} = ConnMod:getstat(Sock, [send_oct]),
put(send_oct, Val),
{keep_state, ensure_keepalive_timer(NewState), [hibernate]};
Error -> {stop, Error}
case ConnMod:getstat(Sock, [send_oct]) of
{ok, [{send_oct, Val}]} ->
put(send_oct, Val),
{keep_state, ensure_keepalive_timer(NewState), [hibernate]};
{error, Reason} ->
maybe_shutdown(Reason, State)
end;
{error, Reason} -> maybe_shutdown(Reason, State)
end;
false ->
{keep_state, ensure_keepalive_timer(State), [hibernate]};
{error, Reason} ->
{stop, Reason}
maybe_shutdown(Reason, State)
end;

connected(info, {timeout, TRef, ack}, State = #state{ack_timer = TRef,
Expand Down

0 comments on commit 1dce9bc

Please sign in to comment.