From cb8a3725b4cd1cef2b8091f252dba711d69c3429 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Mon, 20 Dec 2021 14:22:06 +0800 Subject: [PATCH 1/2] fix: disconnect the client due to exceed receive-maximum packets As described in the 5.0 specification, we should disconnect clients that exceed the receive-maximum limit. > If it receives more than Receive Maximum QoS 1 and QoS 2 PUBLISH packets where it has not sent a PUBACK or PUBCOMP in response, **the Server uses a DISCONNECT packet with Reason Code 0x9** fix: #6447 --- src/emqx_channel.erl | 2 +- test/emqx_channel_SUITE.erl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index f33b3b337..2774ac264 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -599,7 +599,7 @@ do_publish(PacketId, Msg = #message{qos = ?QOS_2}, ?LOG(warning, "Dropped the qos2 packet ~w " "due to awaiting_rel is full.", [PacketId]), ok = emqx_metrics:inc('packets.publish.dropped'), - handle_out(pubrec, {PacketId, RC}, Channel) + handle_out(disconnect, RC, Channel) end. ensure_quota(_, Channel = #channel{quota = undefined}) -> diff --git a/test/emqx_channel_SUITE.erl b/test/emqx_channel_SUITE.erl index 3249eb991..97b77ca88 100644 --- a/test/emqx_channel_SUITE.erl +++ b/test/emqx_channel_SUITE.erl @@ -209,7 +209,8 @@ t_handle_in_qos2_publish_with_error_return(_) -> {ok, ?PUBREC_PACKET(2, ?RC_NO_MATCHING_SUBSCRIBERS), Channel1} = emqx_channel:handle_in(Publish2, Channel), Publish3 = ?PUBLISH_PACKET(?QOS_2, <<"topic">>, 3, <<"payload">>), - {ok, ?PUBREC_PACKET(3, ?RC_RECEIVE_MAXIMUM_EXCEEDED), Channel1} = + {ok, [{outgoing, ?DISCONNECT_PACKET(?RC_RECEIVE_MAXIMUM_EXCEEDED)}, + {close, receive_maximum_exceeded}], Channel1} = emqx_channel:handle_in(Publish3, Channel1). t_handle_in_puback_ok(_) -> From 02dc216173b024eb616ac83fa7d80167cdb3f027 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Mon, 20 Dec 2021 14:34:40 +0800 Subject: [PATCH 2/2] chore: update appup.src --- src/emqx.app.src | 2 +- src/emqx.appup.src | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/emqx.app.src b/src/emqx.app.src index b0e1664cc..1119deccb 100644 --- a/src/emqx.app.src +++ b/src/emqx.app.src @@ -1,7 +1,7 @@ {application, emqx, [{id, "emqx"}, {description, "EMQ X"}, - {vsn, "4.3.12"}, % strict semver, bump manually! + {vsn, "4.3.13"}, % strict semver, bump manually! {modules, []}, {registered, []}, {applications, [kernel,stdlib,gproc,gen_rpc,esockd,cowboy,sasl,os_mon]}, diff --git a/src/emqx.appup.src b/src/emqx.appup.src index 456f89e6c..c4885b7b1 100644 --- a/src/emqx.appup.src +++ b/src/emqx.appup.src @@ -1,6 +1,8 @@ %% -*- mode: erlang -*- {VSN, - [{"4.3.11", + [{"4.3.12", + [{load_module,emqx_channel,brutal_purge,soft_purge,[]}]}, + {"4.3.11", [{load_module,emqx_connection,brutal_purge,soft_purge,[]}, {load_module,emqx_channel,brutal_purge,soft_purge,[]}, {load_module,emqx_vm,brutal_purge,soft_purge,[]}, @@ -196,7 +198,9 @@ {load_module,emqx_rpc,brutal_purge,soft_purge,[]}, {load_module,emqx_app,brutal_purge,soft_purge,[]}]}, {<<".*">>,[]}], - [{"4.3.11", + [{"4.3.12", + [{load_module,emqx_channel,brutal_purge,soft_purge,[]}]}, + {"4.3.11", [{load_module,emqx_connection,brutal_purge,soft_purge,[]}, {load_module,emqx_channel,brutal_purge,soft_purge,[]}, {load_module,emqx_vm,brutal_purge,soft_purge,[]},