From 198da2c688c9bae610f745ca8fd8b8b34aea63ca Mon Sep 17 00:00:00 2001 From: zhouzb Date: Wed, 24 Mar 2021 16:50:28 +0800 Subject: [PATCH] fix(ping): deny pingreq when mqtt not connected --- src/emqx_connection.erl | 3 --- src/emqx_ws_connection.erl | 3 --- test/emqx_connection_SUITE.erl | 1 - 3 files changed, 7 deletions(-) diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index 2ab7f6c1e..be2131565 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -343,9 +343,6 @@ handle_msg({incoming, Packet = ?CONNECT_PACKET(ConnPkt)}, }, handle_incoming(Packet, NState); -handle_msg({incoming, ?PACKET(?PINGREQ)}, State) -> - handle_outgoing(?PACKET(?PINGRESP), State); - handle_msg({incoming, Packet}, State) -> handle_incoming(Packet, State); diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index 33b882768..561e1d2fe 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -296,9 +296,6 @@ websocket_info({incoming, Packet = ?CONNECT_PACKET(ConnPkt)}, State) -> NState = State#state{serialize = Serialize}, handle_incoming(Packet, cancel_idle_timer(NState)); -websocket_info({incoming, ?PACKET(?PINGREQ)}, State) -> - return(enqueue(?PACKET(?PINGRESP), State)); - websocket_info({incoming, Packet}, State) -> handle_incoming(Packet, State); diff --git a/test/emqx_connection_SUITE.erl b/test/emqx_connection_SUITE.erl index b908fe4ab..e92b38908 100644 --- a/test/emqx_connection_SUITE.erl +++ b/test/emqx_connection_SUITE.erl @@ -165,7 +165,6 @@ t_handle_msg(_) -> t_handle_msg_incoming(_) -> ?assertMatch({ok, _Out, _St}, emqx_connection:handle_msg({incoming, ?CONNECT_PACKET(#mqtt_packet_connect{})}, st())), - ?assertEqual(ok, emqx_connection:handle_msg({incoming, ?PACKET(?PINGREQ)}, st())), ok = meck:expect(emqx_channel, handle_in, fun(_Packet, Channel) -> {ok, Channel} end), ?assertMatch({ok, _St}, emqx_connection:handle_msg({incoming, ?PUBLISH_PACKET(?QOS_1, <<"t">>, 1, <<"payload">>)}, st())), ?assertMatch({ok, _St}, emqx_connection:handle_msg({incoming, <>}, st())),