fix(channel): send DISCONNECT packet if connection has been kicked
fix #7241
This commit is contained in:
parent
bce4ca2fbd
commit
8d3e953eef
|
@ -926,7 +926,13 @@ return_sub_unsub_ack(Packet, Channel) ->
|
|||
| {shutdown, Reason :: term(), Reply :: term(), emqx_types:packet(), channel()}).
|
||||
handle_call(kick, Channel) ->
|
||||
Channel1 = ensure_disconnected(kicked, Channel),
|
||||
disconnect_and_shutdown(kicked, ok, Channel1);
|
||||
case Channel1 of
|
||||
?IS_MQTT_V5 ->
|
||||
shutdown(kicked, ok,
|
||||
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION), Channel1);
|
||||
_ ->
|
||||
shutdown(kicked, ok, Channel1)
|
||||
end;
|
||||
|
||||
handle_call(discard, Channel) ->
|
||||
disconnect_and_shutdown(discarded, ok, Channel);
|
||||
|
|
|
@ -577,7 +577,12 @@ t_handle_out_unexpected(_) ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
t_handle_call_kick(_) ->
|
||||
{shutdown, kicked, ok, _Chan} = emqx_channel:handle_call(kick, channel()).
|
||||
Channelv5 = channel(),
|
||||
Channelv4 = v4(Channelv5),
|
||||
{shutdown, kicked, ok, _} = emqx_channel:handle_call(kick, Channelv4),
|
||||
{shutdown, kicked, ok,
|
||||
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION),
|
||||
_} = emqx_channel:handle_call(kick, Channelv5).
|
||||
|
||||
t_handle_call_discard(_) ->
|
||||
Packet = ?DISCONNECT_PACKET(?RC_SESSION_TAKEN_OVER),
|
||||
|
@ -858,3 +863,11 @@ session(InitFields) when is_map(InitFields) ->
|
|||
quota() ->
|
||||
emqx_limiter:init(zone, [{conn_messages_routing, {5, 1}},
|
||||
{overall_messages_routing, {10, 1}}]).
|
||||
|
||||
v4(Channel) ->
|
||||
ConnInfo = emqx_channel:info(conninfo, Channel),
|
||||
emqx_channel:set_field(
|
||||
conninfo,
|
||||
maps:put(proto_ver, ?MQTT_PROTO_V4, ConnInfo),
|
||||
Channel
|
||||
).
|
||||
|
|
Loading…
Reference in New Issue