From d628c49f16497bf0d59f323a494fd649faeb2b27 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 25 Dec 2020 10:15:43 +0800 Subject: [PATCH] fix(management): make client format function durable --- apps/emqx_management/src/emqx_mgmt.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt.erl b/apps/emqx_management/src/emqx_mgmt.erl index 6036d5830..15b58d15f 100644 --- a/apps/emqx_management/src/emqx_mgmt.erl +++ b/apps/emqx_management/src/emqx_mgmt.erl @@ -866,7 +866,11 @@ item(client, {ClientId, ChanPid}) -> end, ClientInfo = maps:get(clientinfo, Attrs, #{}), ConnInfo = maps:get(conninfo, Attrs, #{}), - Session = maps:get(session, Attrs, #{}), + Session = case maps:get(session, Attrs, #{}) of + undefined -> #{}; + _Sess -> _Sess + end, + SessCreated = maps:get(created_at, Session, maps:get(connected_at, ConnInfo)), Connected = case maps:get(conn_state, Attrs) of connected -> true; _ -> false @@ -889,7 +893,7 @@ item(client, {ClientId, ChanPid}) -> maps:with([clientid, username, mountpoint, is_bridge, zone], ClientInfo), maps:with([clean_start, keepalive, expiry_interval, proto_name, proto_ver, peername, connected_at, disconnected_at], ConnInfo), - maps:with([created_at], Session)]); + #{created_at => SessCreated}]); item(subscription, {{Topic, ClientId}, Options}) -> #{topic => Topic, clientid => ClientId, options => Options};