diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index a3cbc1157..93daf4cba 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -310,6 +310,9 @@ handle({call, From}, Req, State = #state{chan_state = ChanState}) -> stop(Reason, State#state{chan_state = NChanState}) end; +handle(cast, discard, State) -> + shutdown(discarded, State); + %% Handle cast handle(cast, Msg, State = #state{chan_state = ChanState}) -> case emqx_channel:handle_cast(Msg, ChanState) of diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index d682d74ab..e28f74b06 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -244,6 +244,9 @@ websocket_info({call, From, Req}, State = #state{chan_state = ChanState}) -> stop(Reason, State#state{chan_state = NChanState}) end; +websocket_info({cast, discard}, State) -> + stop(discarded, State); + websocket_info({cast, Msg}, State = #state{chan_state = ChanState}) -> case emqx_channel:handle_cast(Msg, ChanState) of {ok, NChanState} -> @@ -295,10 +298,6 @@ websocket_info({timeout, TRef, emit_stats}, State) when is_reference(TRef) -> websocket_info({timeout, TRef, Msg}, State) when is_reference(TRef) -> handle_timeout(TRef, Msg, State); -websocket_info({shutdown, discard, {ClientId, ByPid}}, State) -> - ?LOG(warning, "Discarded by ~s:~p", [ClientId, ByPid]), - stop(discard, State); - websocket_info({shutdown, conflict, {ClientId, NewPid}}, State) -> ?LOG(warning, "Clientid '~s' conflict with ~p", [ClientId, NewPid]), stop(conflict, State);