diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index fbe0a8118..e577fd2cc 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -442,6 +442,11 @@ handle_incoming(Packet = ?PACKET(Type), SuccFun, State = #state{chan_state = Cha {ok, OutPackets, NChanState} -> NState = State#state{chan_state = NChanState}, handle_outgoing(OutPackets, SuccFun, NState); + {close, Reason, NChanState} -> + close(Reason, State#state{chan_state = NChanState}); + {close, Reason, OutPackets, NChanState} -> + NState = State#state{chan_state= NChanState}, + close(Reason, handle_outgoing(OutPackets, fun(NewSt) -> NewSt end, NState)); {stop, Reason, NChanState} -> stop(Reason, State#state{chan_state = NChanState}); {stop, Reason, OutPackets, NChanState} -> diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index fe6566364..7434fe932 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -279,7 +279,7 @@ websocket_info(Info, State = #state{chan_state = ChanState}) -> end. terminate(SockError, _Req, #state{chan_state = ChanState, - stop_reason = Reason}) -> + stop_reason = Reason}) -> ?LOG(debug, "Terminated for ~p, sockerror: ~p", [Reason, SockError]), emqx_channel:terminate(Reason, ChanState).