chore: log the bad mqtt packet(frame error)

This commit is contained in:
Zhongwen Deng 2023-01-30 15:05:49 +08:00
parent 3d07271ea5
commit b73d11675e
2 changed files with 6 additions and 2 deletions

View File

@ -102,4 +102,4 @@ enrich_topic(Msg, _) ->
Msg.
mfa(undefined) -> undefined;
mfa({M, F, A}) -> atom_to_list(M) ++ ":" ++ atom_to_list(F) ++ "/" ++ integer_to_list(A).
mfa({M, F, A}) -> [atom_to_list(M), ":", atom_to_list(F), "/" ++ integer_to_list(A)].

View File

@ -479,7 +479,11 @@ format(#mqtt_packet{header = Header, variable = Variable, payload = Payload}, Pa
case format_variable(Variable, Payload, PayloadEncode) of
"" -> [HeaderIO, ")"];
VarIO -> [HeaderIO, ", ", VarIO, ")"]
end.
end;
%% receive a frame error packet, such as {frame_error,frame_too_large} or
%% {frame_error,#{expected => <<"'MQTT' or 'MQIsdp'">>,hint => invalid_proto_name,received => <<"bad_name">>}}
format(FrameError, _PayloadEncode) ->
lists:flatten(io_lib:format("~tp", [FrameError])).
format_header(#mqtt_packet_header{
type = Type,