diff --git a/src/emqx_protocol.erl b/src/emqx_protocol.erl index 88f07138d..1fb80c0ce 100644 --- a/src/emqx_protocol.erl +++ b/src/emqx_protocol.erl @@ -412,12 +412,14 @@ process_packet(?DISCONNECT_PACKET(?RC_SUCCESS, #{'Session-Expiry-Interval' := In case Interval =/= 0 andalso OldInterval =:= 0 of true -> deliver({disconnect, ?RC_PROTOCOL_ERROR}, PState), - {error, protocol_error, PState}; + {error, protocol_error, PState#pstate{will_msg = undefined}}; false -> emqx_session:update_expiry_interval(SPid, Interval), %% Clean willmsg {stop, normal, PState#pstate{will_msg = undefined}} end; +process_packet(?DISCONNECT_PACKET(?RC_SUCCESS), PState) -> + {stop, normal, PState#pstate{will_msg = undefined}}; process_packet(?DISCONNECT_PACKET(_), PState) -> {stop, normal, PState}.