fix(gw_jt808): client keepalive timer

This commit is contained in:
JimMoen 2023-12-14 02:27:14 +08:00
parent 0b1838a5ff
commit d1adcd464e
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
2 changed files with 6 additions and 3 deletions

View File

@ -416,7 +416,7 @@ handle_info({sock_closed, Reason}, Channel = #channel{conn_state = disconnected}
log(error, #{msg => "unexpected_sock_closed", reason => Reason}, Channel),
{ok, Channel};
handle_info(Info, Channel) ->
log(error, #{msg => "unexpected_info}", info => Info}, Channel),
log(error, #{msg => "unexpected_info", info => Info}, Channel),
{ok, Channel}.
%%--------------------------------------------------------------------

View File

@ -48,7 +48,7 @@
%% AuthCode
authcode :: undefined | anonymous | binary(),
%% Keepalive
keepalive,
keepalive :: maybe(emqx_keepalive:keepalive()),
%% Msg SN
msg_sn,
%% Down Topic
@ -188,7 +188,7 @@ init(
conn_state = idle,
timers = #{},
authcode = undefined,
keepalive = maps:get(keepalive, Options, ?DEFAULT_KEEPALIVE),
keepalive = undefined,
msg_sn = 0,
% TODO: init rsa_key from user input
dn_topic = maps:get(dn_topic, ProtoConf, ?DEFAULT_DN_TOPIC),
@ -475,6 +475,9 @@ handle_info(
handle_info({sock_closed, Reason}, Channel = #channel{conn_state = disconnected}) ->
log(error, #{msg => "unexpected_sock_closed", reason => Reason}, Channel),
{ok, Channel};
handle_info({keepalive, start, Interval}, Channel) ->
NChannel = Channel#channel{keepalive = emqx_keepalive:init(Interval)},
{ok, ensure_timer(alive_timer, NChannel)};
handle_info(Info, Channel) ->
log(error, #{msg => "unexpected_info", info => Info}, Channel),
{ok, Channel}.