Fix the issue that protocol is undefined

This commit is contained in:
zhouzb 2019-09-05 18:28:17 +08:00
parent 1e4c51f080
commit de44a89c21
1 changed files with 4 additions and 1 deletions

View File

@ -525,7 +525,10 @@ handle_out({connack, ReasonCode}, Channel = #channel{client = Client,
protocol = Protocol
}) ->
ok = emqx_hooks:run('client.connected', [Client, ReasonCode, attrs(Channel)]),
ProtoVer = emqx_protocol:info(proto_ver, Protocol),
ProtoVer = case Protocol of
undefined -> undefined;
_ -> emqx_protocol:info(proto_ver, Protocol)
end,
ReasonCode1 = if
ProtoVer == ?MQTT_PROTO_V5 -> ReasonCode;
true -> emqx_reason_codes:compat(connack, ReasonCode)