fix(emqx_channel): aovid logging frame errors as exceptions
This commit is contained in:
parent
abbee4bc47
commit
f66d9e76fe
|
@ -564,11 +564,13 @@ handle_in(
|
||||||
handle_in(?AUTH_PACKET(), Channel) ->
|
handle_in(?AUTH_PACKET(), Channel) ->
|
||||||
handle_out(disconnect, ?RC_IMPLEMENTATION_SPECIFIC_ERROR, Channel);
|
handle_out(disconnect, ?RC_IMPLEMENTATION_SPECIFIC_ERROR, Channel);
|
||||||
handle_in({frame_error, Reason}, Channel = #channel{conn_state = idle}) ->
|
handle_in({frame_error, Reason}, Channel = #channel{conn_state = idle}) ->
|
||||||
shutdown(Reason, Channel);
|
shutdown(shutdown_count(frame_error, Reason), Channel);
|
||||||
handle_in({frame_error, frame_too_large}, Channel = #channel{conn_state = connecting}) ->
|
handle_in({frame_error, frame_too_large}, Channel = #channel{conn_state = connecting}) ->
|
||||||
shutdown(frame_too_large, ?CONNACK_PACKET(?RC_PACKET_TOO_LARGE), Channel);
|
shutdown(
|
||||||
|
shutdown_count(frame_error, frame_too_large), ?CONNACK_PACKET(?RC_PACKET_TOO_LARGE), Channel
|
||||||
|
);
|
||||||
handle_in({frame_error, Reason}, Channel = #channel{conn_state = connecting}) ->
|
handle_in({frame_error, Reason}, Channel = #channel{conn_state = connecting}) ->
|
||||||
shutdown(Reason, ?CONNACK_PACKET(?RC_MALFORMED_PACKET), Channel);
|
shutdown(shutdown_count(frame_error, Reason), ?CONNACK_PACKET(?RC_MALFORMED_PACKET), Channel);
|
||||||
handle_in({frame_error, frame_too_large}, Channel = #channel{conn_state = ConnState}) when
|
handle_in({frame_error, frame_too_large}, Channel = #channel{conn_state = ConnState}) when
|
||||||
ConnState =:= connected orelse ConnState =:= reauthenticating
|
ConnState =:= connected orelse ConnState =:= reauthenticating
|
||||||
->
|
->
|
||||||
|
@ -2211,6 +2213,13 @@ shutdown(success, Reply, Packet, Channel) ->
|
||||||
shutdown(Reason, Reply, Packet, Channel) ->
|
shutdown(Reason, Reply, Packet, Channel) ->
|
||||||
{shutdown, Reason, Reply, Packet, Channel}.
|
{shutdown, Reason, Reply, Packet, Channel}.
|
||||||
|
|
||||||
|
%% process exits with {shutdown, #{shutdown_count := Kind}} will trigger
|
||||||
|
%% make the connection supervisor (esockd) keep a shutdown-counter groupd by Kind
|
||||||
|
shutdown_count(Kind, Reason) when is_map(Reason) ->
|
||||||
|
Reason#{shutdown_count => Kind};
|
||||||
|
shutdown_count(Kind, Reason) ->
|
||||||
|
#{shutdown_count => Kind, reason => Reason}.
|
||||||
|
|
||||||
%% mqtt v5 connected sessions
|
%% mqtt v5 connected sessions
|
||||||
disconnect_and_shutdown(
|
disconnect_and_shutdown(
|
||||||
Reason,
|
Reason,
|
||||||
|
|
|
@ -436,11 +436,11 @@ t_handle_in_auth(_) ->
|
||||||
|
|
||||||
t_handle_in_frame_error(_) ->
|
t_handle_in_frame_error(_) ->
|
||||||
IdleChannel = channel(#{conn_state => idle}),
|
IdleChannel = channel(#{conn_state => idle}),
|
||||||
{shutdown, frame_too_large, _Chan} =
|
{shutdown, #{shutdown_count := frame_error, reason := frame_too_large}, _Chan} =
|
||||||
emqx_channel:handle_in({frame_error, frame_too_large}, IdleChannel),
|
emqx_channel:handle_in({frame_error, frame_too_large}, IdleChannel),
|
||||||
ConnectingChan = channel(#{conn_state => connecting}),
|
ConnectingChan = channel(#{conn_state => connecting}),
|
||||||
ConnackPacket = ?CONNACK_PACKET(?RC_PACKET_TOO_LARGE),
|
ConnackPacket = ?CONNACK_PACKET(?RC_PACKET_TOO_LARGE),
|
||||||
{shutdown, frame_too_large, ConnackPacket, _} =
|
{shutdown, #{shutdown_count := frame_error, reason := frame_too_large}, ConnackPacket, _} =
|
||||||
emqx_channel:handle_in({frame_error, frame_too_large}, ConnectingChan),
|
emqx_channel:handle_in({frame_error, frame_too_large}, ConnectingChan),
|
||||||
DisconnectPacket = ?DISCONNECT_PACKET(?RC_PACKET_TOO_LARGE),
|
DisconnectPacket = ?DISCONNECT_PACKET(?RC_PACKET_TOO_LARGE),
|
||||||
ConnectedChan = channel(#{conn_state => connected}),
|
ConnectedChan = channel(#{conn_state => connected}),
|
||||||
|
|
Loading…
Reference in New Issue