fix(clients): fix expiry_interval unit error
It should be second not millisecond
This commit is contained in:
parent
22707495ac
commit
65729cd640
|
@ -65,7 +65,6 @@
|
||||||
{<<"ip_address">>, ip},
|
{<<"ip_address">>, ip},
|
||||||
{<<"conn_state">>, atom},
|
{<<"conn_state">>, atom},
|
||||||
{<<"clean_start">>, atom},
|
{<<"clean_start">>, atom},
|
||||||
{<<"proto_name">>, binary},
|
|
||||||
{<<"proto_ver">>, integer},
|
{<<"proto_ver">>, integer},
|
||||||
{<<"like_clientid">>, binary},
|
{<<"like_clientid">>, binary},
|
||||||
{<<"like_username">>, binary},
|
{<<"like_username">>, binary},
|
||||||
|
@ -145,14 +144,6 @@ schema("/clients") ->
|
||||||
required => false,
|
required => false,
|
||||||
description => <<"Whether the client uses a new session">>
|
description => <<"Whether the client uses a new session">>
|
||||||
})},
|
})},
|
||||||
{proto_name,
|
|
||||||
hoconsc:mk(hoconsc:enum(['MQTT', 'CoAP', 'LwM2M', 'MQTT-SN']), #{
|
|
||||||
in => query,
|
|
||||||
required => false,
|
|
||||||
description =>
|
|
||||||
<<"Client protocol name, ",
|
|
||||||
"the possible values are MQTT,CoAP,LwM2M,MQTT-SN">>
|
|
||||||
})},
|
|
||||||
{proto_ver,
|
{proto_ver,
|
||||||
hoconsc:mk(binary(), #{
|
hoconsc:mk(binary(), #{
|
||||||
in => query,
|
in => query,
|
||||||
|
@ -830,8 +821,6 @@ ms(ip_address, X) ->
|
||||||
#{conninfo => #{peername => {X, '_'}}};
|
#{conninfo => #{peername => {X, '_'}}};
|
||||||
ms(clean_start, X) ->
|
ms(clean_start, X) ->
|
||||||
#{conninfo => #{clean_start => X}};
|
#{conninfo => #{clean_start => X}};
|
||||||
ms(proto_name, X) ->
|
|
||||||
#{conninfo => #{proto_name => X}};
|
|
||||||
ms(proto_ver, X) ->
|
ms(proto_ver, X) ->
|
||||||
#{conninfo => #{proto_ver => X}};
|
#{conninfo => #{proto_ver => X}};
|
||||||
ms(connected_at, X) ->
|
ms(connected_at, X) ->
|
||||||
|
@ -879,7 +868,8 @@ format_channel_info(WhichNode, {_, ClientInfo0, ClientStats}) ->
|
||||||
ClientInfoMap2 = maps:put(node, Node, ClientInfoMap1),
|
ClientInfoMap2 = maps:put(node, Node, ClientInfoMap1),
|
||||||
ClientInfoMap3 = maps:put(ip_address, IpAddress, ClientInfoMap2),
|
ClientInfoMap3 = maps:put(ip_address, IpAddress, ClientInfoMap2),
|
||||||
ClientInfoMap4 = maps:put(port, Port, ClientInfoMap3),
|
ClientInfoMap4 = maps:put(port, Port, ClientInfoMap3),
|
||||||
ClientInfoMap = maps:put(connected, Connected, ClientInfoMap4),
|
ClientInfoMap5 = convert_expiry_interval_unit(ClientInfoMap4),
|
||||||
|
ClientInfoMap = maps:put(connected, Connected, ClientInfoMap5),
|
||||||
|
|
||||||
RemoveList =
|
RemoveList =
|
||||||
[
|
[
|
||||||
|
@ -949,6 +939,9 @@ peername_dispart({Addr, Port}) ->
|
||||||
%% PortBinary = integer_to_binary(Port),
|
%% PortBinary = integer_to_binary(Port),
|
||||||
{AddrBinary, Port}.
|
{AddrBinary, Port}.
|
||||||
|
|
||||||
|
convert_expiry_interval_unit(ClientInfoMap = #{expiry_interval := Interval}) ->
|
||||||
|
ClientInfoMap#{expiry_interval := Interval div 1000}.
|
||||||
|
|
||||||
format_authz_cache({{PubSub, Topic}, {AuthzResult, Timestamp}}) ->
|
format_authz_cache({{PubSub, Topic}, {AuthzResult, Timestamp}}) ->
|
||||||
#{
|
#{
|
||||||
access => PubSub,
|
access => PubSub,
|
||||||
|
|
|
@ -44,7 +44,10 @@ t_clients(_) ->
|
||||||
AuthHeader = emqx_mgmt_api_test_util:auth_header_(),
|
AuthHeader = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
|
|
||||||
{ok, C1} = emqtt:start_link(#{
|
{ok, C1} = emqtt:start_link(#{
|
||||||
username => Username1, clientid => ClientId1, proto_ver => v5
|
username => Username1,
|
||||||
|
clientid => ClientId1,
|
||||||
|
proto_ver => v5,
|
||||||
|
properties => #{'Session-Expiry-Interval' => 120}
|
||||||
}),
|
}),
|
||||||
{ok, _} = emqtt:connect(C1),
|
{ok, _} = emqtt:connect(C1),
|
||||||
{ok, C2} = emqtt:start_link(#{username => Username2, clientid => ClientId2}),
|
{ok, C2} = emqtt:start_link(#{username => Username2, clientid => ClientId2}),
|
||||||
|
@ -70,6 +73,7 @@ t_clients(_) ->
|
||||||
Client1Response = emqx_json:decode(Client1, [return_maps]),
|
Client1Response = emqx_json:decode(Client1, [return_maps]),
|
||||||
?assertEqual(Username1, maps:get(<<"username">>, Client1Response)),
|
?assertEqual(Username1, maps:get(<<"username">>, Client1Response)),
|
||||||
?assertEqual(ClientId1, maps:get(<<"clientid">>, Client1Response)),
|
?assertEqual(ClientId1, maps:get(<<"clientid">>, Client1Response)),
|
||||||
|
?assertEqual(120, maps:get(<<"expiry_interval">>, Client1Response)),
|
||||||
|
|
||||||
%% delete /clients/:clientid kickout
|
%% delete /clients/:clientid kickout
|
||||||
Client2Path = emqx_mgmt_api_test_util:api_path(["clients", binary_to_list(ClientId2)]),
|
Client2Path = emqx_mgmt_api_test_util:api_path(["clients", binary_to_list(ClientId2)]),
|
||||||
|
|
Loading…
Reference in New Issue