From e6df089ecb2f79d3c3d7b10ebf6351b9a753618a Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Mon, 10 Apr 2017 13:37:50 +0800 Subject: [PATCH 01/12] Fix issue #984 - support HEAD method for health check --- src/emqttd_http.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd_http.erl b/src/emqttd_http.erl index 692477447..25b7c3d23 100644 --- a/src/emqttd_http.erl +++ b/src/emqttd_http.erl @@ -31,7 +31,7 @@ handle_request(Req) -> handle_request(Req:get(method), Req:get(path), Req). -handle_request('GET', "/status", Req) -> +handle_request(Method, "/status", Req) when Method =:= 'HEAD'; Method =:= 'GET' -> {InternalStatus, _ProvidedStatus} = init:get_status(), AppStatus = case lists:keysearch(emqttd, 1, application:which_applications()) of From 43cc90ceae73cddc8e28569308e8d12dd93e3d2f Mon Sep 17 00:00:00 2001 From: turtled Date: Tue, 11 Apr 2017 09:40:31 +0800 Subject: [PATCH 02/12] bridge message qos default 0 --- src/emqttd_bridge.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emqttd_bridge.erl b/src/emqttd_bridge.erl index a1dd34bcc..815ee38d9 100644 --- a/src/emqttd_bridge.erl +++ b/src/emqttd_bridge.erl @@ -37,7 +37,7 @@ -record(state, {pool, id, node, subtopic, - qos = ?QOS_2, + qos = ?QOS_0, topic_suffix = <<>>, topic_prefix = <<>>, mqueue :: emqttd_mqueue:mqueue(), @@ -74,7 +74,7 @@ init([Pool, Id, Node, Topic, Options]) -> true -> true = erlang:monitor_node(Node, true), Share = iolist_to_binary(["$bridge:", atom_to_list(Node), ":", Topic]), - emqttd:subscribe(Topic, self(), [local, {share, Share}]), + emqttd:subscribe(Topic, self(), [local, {share, Share}, {qos, ?QOS_0}]), State = parse_opts(Options, #state{node = Node, subtopic = Topic}), MQueue = emqttd_mqueue:new(qname(Node, Topic), [{max_len, State#state.max_queue_len}], From 6effb5fdbe9867e0e87168bb8e60eafaf47ec6cc Mon Sep 17 00:00:00 2001 From: huangdan Date: Thu, 13 Apr 2017 10:02:32 +0800 Subject: [PATCH 03/12] Version 2.1.1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 626f969a2..69347e2ae 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PROJECT = emqttd PROJECT_DESCRIPTION = Erlang MQTT Broker -PROJECT_VERSION = 2.1.0 +PROJECT_VERSION = 2.1.1 DEPS = goldrush gproc lager esockd mochiweb pbkdf2 lager_syslog From b10938c90a725c49a8095adc3372a3359289b38c Mon Sep 17 00:00:00 2001 From: huangdan Date: Thu, 13 Apr 2017 10:24:50 +0800 Subject: [PATCH 04/12] Version 2.1.1 --- 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 d03a4d952..2e63d388e 100644 --- a/src/emqttd.app.src +++ b/src/emqttd.app.src @@ -1,6 +1,6 @@ {application, emqttd, [ {description, "Erlang MQTT Broker"}, - {vsn, "2.1.0"}, + {vsn, "2.1.1"}, {modules, []}, {registered, [emqttd_sup]}, {applications, [kernel,stdlib,gproc,lager,esockd,mochiweb,lager_syslog,pbkdf2]}, From 0cbca5f4c01ca1fc82d1498ac5f5fa8a5821ef63 Mon Sep 17 00:00:00 2001 From: HuangDan Date: Thu, 13 Apr 2017 15:09:48 +0800 Subject: [PATCH 05/12] Fix the subscrptions print --- src/emqttd_cli.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index 54d462e65..dddf03470 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -553,10 +553,10 @@ print({ClientId, _ClientPid, _Persistent, SessInfo}) -> "deliver_msg=~w, enqueue_msg=~w, created_at=~w)~n", [ClientId | [format(Key, get_value(Key, Data)) || Key <- InfoKeys]]). -print(subscription, {Sub, Topic}) when is_pid(Sub) -> - ?PRINT("~p -> ~s~n", [Sub, Topic]); print(subscription, {Sub, {_Share, Topic}}) when is_pid(Sub) -> ?PRINT("~p -> ~s~n", [Sub, Topic]); +print(subscription, {Sub, Topic}) when is_pid(Sub) -> + ?PRINT("~p -> ~s~n", [Sub, Topic]); print(subscription, {Sub, {_Share, Topic}}) -> ?PRINT("~s -> ~s~n", [Sub, Topic]); print(subscription, {Sub, Topic}) -> From 9157f824e5a867977e9a866670a42a24bb0e75a7 Mon Sep 17 00:00:00 2001 From: HuangDan Date: Sat, 15 Apr 2017 23:52:54 +0800 Subject: [PATCH 06/12] Fix sessions list command --- src/emqttd_cli.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index dddf03470..34995d8c8 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -548,7 +548,7 @@ print({ClientId, _ClientPid, _Persistent, SessInfo}) -> deliver_msg, enqueue_msg, created_at], - ?PRINT("Session(~s, clean_sess=~s, max_inflight=~w, inflight=~w, " + ?PRINT("Session(~s, clean_sess=~s, subscription=~w, max_inflight=~w, inflight=~w, " "mqueue_len=~w, mqueue_dropped=~w, awaiting_rel=~w, " "deliver_msg=~w, enqueue_msg=~w, created_at=~w)~n", [ClientId | [format(Key, get_value(Key, Data)) || Key <- InfoKeys]]). From aa360d4378467159f049d17c59d7467ddb4a8b69 Mon Sep 17 00:00:00 2001 From: turtled Date: Tue, 18 Apr 2017 16:44:19 +0800 Subject: [PATCH 07/12] Fix duplicate send pubrec packet --- src/emqttd_session.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 85b027781..5e9dbd4ee 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -733,9 +733,14 @@ acked(puback, PacketId, State = #state{client_id = ClientId, acked(pubrec, PacketId, State = #state{client_id = ClientId, username = Username, inflight = Inflight}) -> - {publish, Msg, _Ts} = Inflight:lookup(PacketId), - emqttd_hooks:run('message.acked', [ClientId, Username], Msg), - State#state{inflight = Inflight:update(PacketId, {pubrel, PacketId, os:timestamp()})}; + case Inflight:lookup(PacketId) of + {publish, Msg, _Ts} -> + emqttd_hooks:run('message.acked', [ClientId, Username], Msg), + State#state{inflight = Inflight:update(PacketId, {pubrel, PacketId, os:timestamp()})}; + {pubrel, PacketId, _Ts} -> + ?LOG(error, "~p packet_id:~p, duplicate send pubrec packet", [ClientId, PacketId], State), + State + end; acked(pubcomp, PacketId, State = #state{inflight = Inflight}) -> State#state{inflight = Inflight:delete(PacketId)}. From 9d3676884ca53206b93c43219891108c34e840c8 Mon Sep 17 00:00:00 2001 From: turtled Date: Tue, 18 Apr 2017 17:19:04 +0800 Subject: [PATCH 08/12] Fix duplicate send pubrec packet --- src/emqttd_session.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 5e9dbd4ee..d9ba581e9 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -738,7 +738,7 @@ acked(pubrec, PacketId, State = #state{client_id = ClientId, emqttd_hooks:run('message.acked', [ClientId, Username], Msg), State#state{inflight = Inflight:update(PacketId, {pubrel, PacketId, os:timestamp()})}; {pubrel, PacketId, _Ts} -> - ?LOG(error, "~p packet_id:~p, duplicate send pubrec packet", [ClientId, PacketId], State), + ?LOG(warning, "Duplicated PUBREC Packet: ~p", [PacketId], State), State end; From 7ca6cbadcf5404c15b66732acfafe42e28e77741 Mon Sep 17 00:00:00 2001 From: turtled Date: Tue, 18 Apr 2017 17:32:00 +0800 Subject: [PATCH 09/12] Duplicated PUBACK Packet --- src/emqttd_session.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index d9ba581e9..65d773e0d 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -726,9 +726,14 @@ await(Msg = #mqtt_message{pktid = PacketId}, acked(puback, PacketId, State = #state{client_id = ClientId, username = Username, inflight = Inflight}) -> - {publish, Msg, _Ts} = Inflight:lookup(PacketId), - emqttd_hooks:run('message.acked', [ClientId, Username], Msg), - State#state{inflight = Inflight:delete(PacketId)}; + case Inflight:lookup(PacketId) of + {publish, Msg, _Ts} -> + emqttd_hooks:run('message.acked', [ClientId, Username], Msg), + State#state{inflight = Inflight:delete(PacketId)}; + _ -> + ?LOG(warning, "Duplicated PUBACK Packet: ~p", [PacketId], State), + State + end; acked(pubrec, PacketId, State = #state{client_id = ClientId, username = Username, From 6a14c7c1b9bb55d946742dbf2e172699b5770fd5 Mon Sep 17 00:00:00 2001 From: huangdan Date: Thu, 20 Apr 2017 09:48:34 +0800 Subject: [PATCH 10/12] Version 2.1.2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 69347e2ae..054a59467 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PROJECT = emqttd PROJECT_DESCRIPTION = Erlang MQTT Broker -PROJECT_VERSION = 2.1.1 +PROJECT_VERSION = 2.1.2 DEPS = goldrush gproc lager esockd mochiweb pbkdf2 lager_syslog From dcecd7d8aec389df37bb36ce4a948d611a70e043 Mon Sep 17 00:00:00 2001 From: huangdan Date: Thu, 20 Apr 2017 09:48:34 +0800 Subject: [PATCH 11/12] Version 2.1.2 --- Makefile | 2 +- src/emqttd.app.src | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 69347e2ae..054a59467 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PROJECT = emqttd PROJECT_DESCRIPTION = Erlang MQTT Broker -PROJECT_VERSION = 2.1.1 +PROJECT_VERSION = 2.1.2 DEPS = goldrush gproc lager esockd mochiweb pbkdf2 lager_syslog diff --git a/src/emqttd.app.src b/src/emqttd.app.src index 2e63d388e..de1af362e 100644 --- a/src/emqttd.app.src +++ b/src/emqttd.app.src @@ -1,6 +1,6 @@ {application, emqttd, [ {description, "Erlang MQTT Broker"}, - {vsn, "2.1.1"}, + {vsn, "2.1.2"}, {modules, []}, {registered, [emqttd_sup]}, {applications, [kernel,stdlib,gproc,lager,esockd,mochiweb,lager_syslog,pbkdf2]}, From 1cfa25861f1ddbb260d194cf74679ec233c14343 Mon Sep 17 00:00:00 2001 From: HuangDan Date: Thu, 20 Apr 2017 14:06:56 +0800 Subject: [PATCH 12/12] Change subscription to subscriptions --- src/emqttd_cli.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index 34995d8c8..8123fe669 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -548,7 +548,7 @@ print({ClientId, _ClientPid, _Persistent, SessInfo}) -> deliver_msg, enqueue_msg, created_at], - ?PRINT("Session(~s, clean_sess=~s, subscription=~w, max_inflight=~w, inflight=~w, " + ?PRINT("Session(~s, clean_sess=~s, subscriptions=~w, max_inflight=~w, inflight=~w, " "mqueue_len=~w, mqueue_dropped=~w, awaiting_rel=~w, " "deliver_msg=~w, enqueue_msg=~w, created_at=~w)~n", [ClientId | [format(Key, get_value(Key, Data)) || Key <- InfoKeys]]).