fix(mgmt): fix client formating crash
see: https://github.com/emqx/emqx/issues/3868
This commit is contained in:
parent
db5ec5bbb7
commit
9b3a6aa635
|
@ -919,7 +919,7 @@ get_telemetry_data() ->
|
||||||
|
|
||||||
item(client, {ClientId, ChanPid}) ->
|
item(client, {ClientId, ChanPid}) ->
|
||||||
Attrs = case emqx_cm:get_chan_info(ClientId, ChanPid) of
|
Attrs = case emqx_cm:get_chan_info(ClientId, ChanPid) of
|
||||||
undefined -> #{};
|
undefined -> throw(gone);
|
||||||
Attrs0 -> Attrs0
|
Attrs0 -> Attrs0
|
||||||
end,
|
end,
|
||||||
Stats = case emqx_cm:get_chan_stats(ClientId, ChanPid) of
|
Stats = case emqx_cm:get_chan_stats(ClientId, ChanPid) of
|
||||||
|
@ -933,7 +933,7 @@ item(client, {ClientId, ChanPid}) ->
|
||||||
_Sess -> _Sess
|
_Sess -> _Sess
|
||||||
end,
|
end,
|
||||||
SessCreated = maps:get(created_at, Session, maps:get(connected_at, ConnInfo)),
|
SessCreated = maps:get(created_at, Session, maps:get(connected_at, ConnInfo)),
|
||||||
Connected = case maps:get(conn_state, Attrs) of
|
Connected = case maps:get(conn_state, Attrs, connected) of
|
||||||
connected -> true;
|
connected -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -250,7 +250,15 @@ parse_ratelimit_str(S) ->
|
||||||
%% Format
|
%% Format
|
||||||
|
|
||||||
format(Items) when is_list(Items) ->
|
format(Items) when is_list(Items) ->
|
||||||
[format(Item) || Item <- Items];
|
lists:foldr(
|
||||||
|
fun(Item, Acc) ->
|
||||||
|
try
|
||||||
|
[format(Item) | Acc]
|
||||||
|
catch
|
||||||
|
throw:gone:_Stk ->
|
||||||
|
Acc
|
||||||
|
end
|
||||||
|
end, [], Items);
|
||||||
format(Key) when is_tuple(Key) ->
|
format(Key) when is_tuple(Key) ->
|
||||||
format(emqx_mgmt:item(client, Key));
|
format(emqx_mgmt:item(client, Key));
|
||||||
format(Data) when is_map(Data)->
|
format(Data) when is_map(Data)->
|
||||||
|
|
Loading…
Reference in New Issue