From bf2e1c39c36e3287b91eae72c01d70acadbd5467 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Sat, 18 Jun 2016 14:10:22 +0800 Subject: [PATCH 1/5] 1.1.2 --- src/emqttd.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd.app.src b/src/emqttd.app.src index 5485a8d46..be726aa9f 100644 --- a/src/emqttd.app.src +++ b/src/emqttd.app.src @@ -1,7 +1,7 @@ {application, emqttd, [ {description, "Erlang MQTT Broker"}, - {vsn, "1.1"}, + {vsn, "1.1.2"}, {id, "emqttd"}, {modules, []}, {registered, []}, From 48183ddca0b4e0817c27930df831a860804fc43c Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Sat, 18 Jun 2016 16:03:51 +0800 Subject: [PATCH 2/5] Upgrade dashboard plugin --- plugins/emqttd_dashboard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/emqttd_dashboard b/plugins/emqttd_dashboard index 26c727be2..f4ed05ee5 160000 --- a/plugins/emqttd_dashboard +++ b/plugins/emqttd_dashboard @@ -1 +1 @@ -Subproject commit 26c727be2b31180780d582e460e20fe418af1909 +Subproject commit f4ed05ee52d487dbab899aafa96b72519725978c From fb7a5d1ccff967e4d8aac17f37f84047444161a9 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 21 Jun 2016 09:21:42 +0800 Subject: [PATCH 3/5] session expired_after 2880 minutes --- docs/source/config.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/config.rst b/docs/source/config.rst index d964205d0..bc5fdf71e 100644 --- a/docs/source/config.rst +++ b/docs/source/config.rst @@ -370,8 +370,8 @@ MQTT Session %% Interval of Statistics Collection(seconds) {collect_interval, 20}, - %% Expired after 2 days - {expired_after, 48} + %% Expired after 2 day (unit: minute) + {expired_after, 2880} ]}, @@ -389,7 +389,7 @@ Session parameters: +----------------------+----------------------------------------------------------+ | collect_interval | Interval of Statistics Collection | +----------------------+----------------------------------------------------------+ -| expired_after | Expired after | +| expired_after | Expired after (unit: minute) | +----------------------+----------------------------------------------------------+ MQTT Message Queue From fe3becbf9be8d6b83cfe5920d2d5f3f68f31e2be Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 21 Jun 2016 11:29:59 +0800 Subject: [PATCH 4/5] Fix issue#599 - Reject empty clientId with non-clean session --- rel/files/emqttd.test.config | 18 ++++++++---------- src/emqttd_protocol.erl | 6 ++++++ test/emqttd_SUITE.erl | 26 ++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/rel/files/emqttd.test.config b/rel/files/emqttd.test.config index c2b90993e..48ad73252 100644 --- a/rel/files/emqttd.test.config +++ b/rel/files/emqttd.test.config @@ -46,7 +46,7 @@ %% Authetication. Anonymous Default {auth, [ %% Authentication with username, password - {username, [{test, "password"}, {"test1", "password1"}]}, + %% {username, [{test, "password"}, {"test1", "password1"}]}, %% Authentication with clientid %{clientid, [{password, no}, {file, "etc/clients.config"}]}, @@ -104,8 +104,8 @@ %% Statistics Collection Interval(seconds) {collect_interval, 20}, - %% Expired after 2 days - {expired_after, 48} + %% Expired after 2 day (unit: minute) + {expired_after, 2880} ]}, %% Queue @@ -173,14 +173,12 @@ %% Subscribe topics automatically when client connected {subscription, [ + + %% $c will be replaced by clientid + %% {"$queue/clients/$c", 1}, + %% Static subscriptions from backend - backend, - - %% $u will be replaced with username - {"$queue/username/$u", 1}, - - %% $c will be replaced with clientid - {"$queue/clients/$c", 1} + backend ]} %% Rewrite rules diff --git a/src/emqttd_protocol.erl b/src/emqttd_protocol.erl index c8fc4fe73..7c8a87146 100644 --- a/src/emqttd_protocol.erl +++ b/src/emqttd_protocol.erl @@ -336,6 +336,12 @@ validate_clientid(#mqtt_packet_connect{client_id = ClientId}, when (size(ClientId) >= 1) andalso (size(ClientId) =< MaxLen) -> true; +%% Issue#599: Null clientId and clean_sess = false +validate_clientid(#mqtt_packet_connect{client_id = ClientId, + clean_sess = CleanSess}, _ProtoState) + when size(ClientId) == 0 andalso (not CleanSess) -> + false; + %% MQTT3.1.1 allow null clientId. validate_clientid(#mqtt_packet_connect{proto_ver =?MQTT_PROTO_V311, client_id = ClientId}, _ProtoState) diff --git a/test/emqttd_SUITE.erl b/test/emqttd_SUITE.erl index ab5480aad..3c507540d 100644 --- a/test/emqttd_SUITE.erl +++ b/test/emqttd_SUITE.erl @@ -23,7 +23,8 @@ -include_lib("eunit/include/eunit.hrl"). all() -> - [{group, pubsub}, + [{group, protocol}, + {group, pubsub}, {group, router}, {group, session}, {group, retainer}, @@ -35,7 +36,9 @@ all() -> {group, cli}]. groups() -> - [{pubsub, [sequence], + [{protocol, [sequence], + [mqtt_connect]}, + {pubsub, [sequence], [create_topic, create_subscription, subscribe_unsubscribe, @@ -88,6 +91,24 @@ end_per_suite(_Config) -> application:stop(gproc), emqttd_mnesia:ensure_stopped(). +%%-------------------------------------------------------------------- +%% Protocol Test +%%-------------------------------------------------------------------- + +mqtt_connect(_) -> + %% Issue #599 + %% Empty clientId and clean_session = false + ?assertEqual(<<32,2,0,2>>, connect_broker_(<<16,12,0,4,77,81,84,84,4,0,0,90,0,0>>, 4)), + %% Empty clientId and clean_session = true + ?assertEqual(<<32,2,0,0>>, connect_broker_(<<16,12,0,4,77,81,84,84,4,2,0,90,0,0>>, 4)). + +connect_broker_(Packet, RecvSize) -> + {ok, Sock} = gen_tcp:connect({127,0,0,1}, 1883, [binary, {packet, raw}, {active, false}]), + gen_tcp:send(Sock, Packet), + {ok, Data} = gen_tcp:recv(Sock, RecvSize, 3000), + gen_tcp:close(Sock), + Data. + %%-------------------------------------------------------------------- %% PubSub Test %%-------------------------------------------------------------------- @@ -156,6 +177,7 @@ pubsub_queue(_) -> Self = self(), Q = <<"$queue/abc">>, SubFun = fun() -> emqttd:subscribe(Q), + timer:sleep(1), {ok, Msgs} = loop_recv(Q, 10), Self ! {recv, self(), Msgs} end, From f273a8635e20e42f9fcd3fa6422d8ec78f46969a Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 25 Jun 2016 20:46:42 +0200 Subject: [PATCH 5/5] typos --- docs/source/config.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/config.rst b/docs/source/config.rst index bc5fdf71e..7ddab18d9 100644 --- a/docs/source/config.rst +++ b/docs/source/config.rst @@ -111,7 +111,7 @@ This is the main emqttd broker configuration file. File Syntax ----------- -The file users the standard Erlang config syntax, consists of a list of erlang applications and their environments. +The file use the standard Erlang config syntax and consists of a list of erlang applications and their environments. .. code-block:: erlang @@ -541,7 +541,7 @@ Plugins Folder TCP Listeners ------------- -Congfigure the TCP listeners for MQTT, MQTT(SSL) and HTTP Protocols. +Configure the TCP listeners for MQTT, MQTT(SSL) and HTTP Protocols. The most important parameter is 'max_clients' - max concurrent clients allowed.