From 23095af55fb5440dc95993915b516b5514a4063d Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Mon, 28 Sep 2015 21:45:44 +0800 Subject: [PATCH 1/9] fix issue #318 --- src/emqttd_auth_mod.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/emqttd_auth_mod.erl b/src/emqttd_auth_mod.erl index 40eb51cfc..a6298a68b 100644 --- a/src/emqttd_auth_mod.erl +++ b/src/emqttd_auth_mod.erl @@ -36,6 +36,8 @@ -ifdef(use_specs). +-callback init(AuthOpts :: list()) -> {ok, State :: any()}. + -callback check(Client, Password, State) -> ok | ignore | {error, string()} when Client :: mqtt_client(), Password :: binary(), @@ -48,7 +50,7 @@ -export([behaviour_info/1]). behaviour_info(callbacks) -> - [{check, 3}, {description, 0}]; + [{init, 1}, {check, 3}, {description, 0}]; behaviour_info(_Other) -> undefined. From 83f8e51a65b34e3388c257ab6b34435f13bffa23 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Mon, 28 Sep 2015 21:48:28 +0800 Subject: [PATCH 2/9] Contributors --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1ad26dab5..6b5ed54ee 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Benchmark 0.6.1-alpha on a ubuntu/14.04 server with 8 cores, 32G memory from Qin * [@huangdan](https://github.com/huangdan) * [@phanimahesh](https://github.com/phanimahesh) * [@dvliman](https://github.com/dvliman) +* [@phanimahesh](https://github.com/phanimahesh) ## Author From 5076301a82b35dc05d867d98c635269af2a645f6 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Mon, 28 Sep 2015 21:53:07 +0800 Subject: [PATCH 3/9] contributors --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6b5ed54ee..1ad26dab5 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,6 @@ Benchmark 0.6.1-alpha on a ubuntu/14.04 server with 8 cores, 32G memory from Qin * [@huangdan](https://github.com/huangdan) * [@phanimahesh](https://github.com/phanimahesh) * [@dvliman](https://github.com/dvliman) -* [@phanimahesh](https://github.com/phanimahesh) ## Author From 23062abbb43d2b0ee9432a3e53035b38a4151a61 Mon Sep 17 00:00:00 2001 From: Feng Date: Tue, 29 Sep 2015 10:08:52 +0800 Subject: [PATCH 4/9] retry interval, and idle_timeout --- rel/files/emqttd.config | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rel/files/emqttd.config b/rel/files/emqttd.config index 3980fba81..55a8a9455 100644 --- a/rel/files/emqttd.config +++ b/rel/files/emqttd.config @@ -81,6 +81,8 @@ ]}, %% Client {client, [ + %% Socket is connected, but no 'CONNECT' packet received + {idle_timeout, 10}, %% seconds %TODO: Network ingoing limit %{ingoing_rate_limit, '64KB/s'} %TODO: Reconnet control @@ -91,20 +93,17 @@ %% 0 means no limit {max_inflight, 100}, - %% Max retries for unack Qos1/2 messages - {unack_retries, 3}, - - %% Retry after 4, 8, 16 seconds - {unack_timeout, 4}, + %% Retry interval for redelivering QoS1/2 messages. + {unack_retry_interval, 20}, %% Awaiting PUBREL Timeout - {await_rel_timeout, 8}, + {await_rel_timeout, 20}, %% Max Packets that Awaiting PUBREL, 0 means no limit {max_awaiting_rel, 0}, %% Statistics Collection Interval(seconds) - {collect_interval, 10}, + {collect_interval, 20}, %% Expired after 2 days {expired_after, 48} From dfc3194d53714765cada064e206aefa48a474742 Mon Sep 17 00:00:00 2001 From: Feng Date: Tue, 29 Sep 2015 10:09:21 +0800 Subject: [PATCH 5/9] env --- src/emqttd.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd.erl b/src/emqttd.erl index e48aee560..21797dd46 100644 --- a/src/emqttd.erl +++ b/src/emqttd.erl @@ -90,7 +90,7 @@ open_listener({https, Port, Options}) -> mochiweb:start_http(Port, Options, MFArgs). open_listener(Protocol, Port, Options) -> - MFArgs = {emqttd_client, start_link, [env(mqtt, packet)]}, + MFArgs = {emqttd_client, start_link, env(mqtt)}, esockd:open(Protocol, Port, merge_sockopts(Options) , MFArgs). merge_sockopts(Options) -> From 86a1f7f7d43c0b4a44f8a02f44b5f6afe57eea3a Mon Sep 17 00:00:00 2001 From: Feng Date: Tue, 29 Sep 2015 10:10:30 +0800 Subject: [PATCH 6/9] fix issue #264 --- src/emqttd_client.erl | 17 +++++++----- src/emqttd_session.erl | 62 ++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/emqttd_client.erl b/src/emqttd_client.erl index c9421413e..da38d9d8d 100644 --- a/src/emqttd_client.erl +++ b/src/emqttd_client.erl @@ -55,8 +55,8 @@ packet_opts, keepalive}). -start_link(SockArgs, PktOpts) -> - {ok, proc_lib:spawn_link(?MODULE, init, [[SockArgs, PktOpts]])}. +start_link(SockArgs, MqttEnv) -> + {ok, proc_lib:spawn_link(?MODULE, init, [[SockArgs, MqttEnv]])}. session(CPid) -> gen_server:call(CPid, session). @@ -70,14 +70,15 @@ kick(CPid) -> subscribe(CPid, TopicTable) -> gen_server:cast(CPid, {subscribe, TopicTable}). -init([SockArgs = {Transport, Sock, _SockFun}, PacketOpts]) -> +init([SockArgs = {Transport, Sock, _SockFun}, MqttEnv]) -> % Transform if ssl. {ok, NewSock} = esockd_connection:accept(SockArgs), {ok, Peername} = emqttd_net:peername(Sock), {ok, ConnStr} = emqttd_net:connection_string(Sock, inbound), lager:info("Connect from ~s", [ConnStr]), SendFun = fun(Data) -> Transport:send(NewSock, Data) end, - ProtoState = emqttd_protocol:init(Peername, SendFun, PacketOpts), + PktOpts = proplists:get_value(packet, MqttEnv), + ProtoState = emqttd_protocol:init(Peername, SendFun, PktOpts), State = control_throttle(#state{transport = Transport, socket = NewSock, peername = Peername, @@ -85,10 +86,12 @@ init([SockArgs = {Transport, Sock, _SockFun}, PacketOpts]) -> await_recv = false, conn_state = running, conserve = false, - packet_opts = PacketOpts, - parser = emqttd_parser:new(PacketOpts), + packet_opts = PktOpts, + parser = emqttd_parser:new(PktOpts), proto_state = ProtoState}), - gen_server:enter_loop(?MODULE, [], State, 10000). + ClientOpts = proplists:get_value(client, MqttEnv), + IdleTimout = proplists:get_value(idle_timeout, ClientOpts, 10), + gen_server:enter_loop(?MODULE, [], State, timer:seconds(IdleTimout)). handle_call(session, _From, State = #state{proto_state = ProtoState}) -> {reply, emqttd_protocol:session(ProtoState), State}; diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 62cb573a6..3db884d55 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -119,11 +119,8 @@ %% Awaiting timers for ack, rel. awaiting_ack :: map(), - %% Retries to resend the unacked messages - unack_retries = 3, - - %% 4, 8, 16 seconds if 3 retries:) - unack_timeout = 4, + %% Retry interval for redelivering QoS1/2 messages + retry_interval = 20, %% Awaiting for PUBCOMP awaiting_comp :: map(), @@ -237,8 +234,7 @@ init([CleanSess, ClientId, ClientPid]) -> awaiting_rel = #{}, awaiting_ack = #{}, awaiting_comp = #{}, - unack_retries = emqttd_opts:g(unack_retries, SessEnv), - unack_timeout = emqttd_opts:g(unack_timeout, SessEnv), + retry_interval = emqttd_opts:g(unack_retry_interval, SessEnv), await_rel_timeout = emqttd_opts:g(await_rel_timeout, SessEnv), max_awaiting_rel = emqttd_opts:g(max_awaiting_rel, SessEnv), expired_after = emqttd_opts:g(expired_after, SessEnv) * 3600, @@ -394,7 +390,7 @@ handle_cast({resume, ClientId, ClientPid}, Session) -> [ClientPid ! {redeliver, {?PUBREL, PktId}} || PktId <- maps:keys(AwaitingComp)], %% Clear awaiting_ack timers - [cancel_timer(TRef) || {_, TRef} <- maps:values(AwaitingAck)], + [cancel_timer(TRef) || TRef <- maps:values(AwaitingAck)], %% Clear awaiting_comp timers [cancel_timer(TRef) || TRef <- maps:values(AwaitingComp)], @@ -408,7 +404,7 @@ handle_cast({resume, ClientId, ClientPid}, Session) -> %% Redeliver inflight messages Session2 = lists:foldl(fun({_Id, Msg}, Sess) -> - redeliver(Msg#mqtt_message{dup = true}, Sess) + redeliver(Msg, Sess) end, Session1, lists:reverse(InflightQ)), %% Dequeue pending messages @@ -417,7 +413,7 @@ handle_cast({resume, ClientId, ClientPid}, Session) -> %% PUBACK handle_cast({puback, PktId}, Session = #session{client_id = ClientId, awaiting_ack = AwaitingAck}) -> case maps:find(PktId, AwaitingAck) of - {ok, {_, TRef}} -> + {ok, TRef} -> cancel_timer(TRef), noreply(dequeue(acked(PktId, Session))); error -> @@ -426,12 +422,12 @@ handle_cast({puback, PktId}, Session = #session{client_id = ClientId, awaiting_a end; %% PUBREC -handle_cast({pubrec, PktId}, Session = #session{client_id = ClientId, - awaiting_ack = AwaitingAck, - awaiting_comp = AwaitingComp, +handle_cast({pubrec, PktId}, Session = #session{client_id = ClientId, + awaiting_ack = AwaitingAck, + awaiting_comp = AwaitingComp, await_rel_timeout = Timeout}) -> case maps:find(PktId, AwaitingAck) of - {ok, {_, TRef}} -> + {ok, TRef} -> cancel_timer(TRef), TRef1 = timer(Timeout, {timeout, awaiting_comp, PktId}), AwaitingComp1 = maps:put(PktId, TRef1, AwaitingComp), @@ -497,22 +493,23 @@ handle_info({timeout, awaiting_ack, PktId}, Session = #session{client_pid = unde %% just remove awaiting noreply(Session#session{awaiting_ack = maps:remove(PktId, AwaitingAck)}); -handle_info({timeout, awaiting_ack, PktId}, Session = #session{inflight_queue = InflightQ, +handle_info({timeout, awaiting_ack, PktId}, Session = #session{client_id = ClientId, + inflight_queue = InflightQ, awaiting_ack = AwaitingAck}) -> case maps:find(PktId, AwaitingAck) of - {ok, {{0, _Timeout}, _TRef}} -> - Session1 = Session#session{inflight_queue = lists:keydelete(PktId, 1, InflightQ), - awaiting_ack = maps:remove(PktId, AwaitingAck)}, - noreply(dequeue(Session1)); - {ok, {{Retries, Timeout}, _TRef}} -> - TRef = timer(Timeout, {timeout, awaiting_ack, PktId}), - AwaitingAck1 = maps:put(PktId, {{Retries-1, Timeout*2}, TRef}, AwaitingAck), - {noreply, Session#session{awaiting_ack = AwaitingAck1}, hibernate}; + {ok, _TRef} -> + case lists:keyfind(PktId, 1, InflightQ) of + {_, Msg} -> + noreply(redeliver(Msg, Session)); + false -> + lager:error([{client, ClientId}], "Session(~s):" + "Awaiting timeout but Cannot find PktId :~p", [ClientId, PktId]), + noreply(dequeue(Session)) + end; error -> - % TODO: too many logs when overloaded... - % lager:error([{client, ClientId}], "Session ~s " - % "Cannot find Awaiting Ack:~p", [ClientId, PktId]), - {noreply, Session, hibernate} + lager:error([{client, ClientId}], "Session(~s):" + "Cannot find Awaiting Ack:~p", [ClientId, PktId]), + noreply(Session) end; handle_info({timeout, awaiting_rel, PktId}, Session = #session{client_id = ClientId, @@ -633,17 +630,16 @@ redeliver(Msg = #mqtt_message{qos = ?QOS_0}, Session) -> redeliver(Msg = #mqtt_message{qos = QoS}, Session = #session{client_pid = ClientPid}) when QoS =:= ?QOS_1 orelse QoS =:= ?QOS_2 -> - ClientPid ! {deliver, Msg}, + ClientPid ! {deliver, Msg#mqtt_message{dup = true}}, await(Msg, Session). %%------------------------------------------------------------------------------ %% Awaiting ack for qos1, qos2 message %%------------------------------------------------------------------------------ -await(#mqtt_message{pktid = PktId}, Session = #session{awaiting_ack = Awaiting, - unack_retries = Retries, - unack_timeout = Timeout}) -> +await(#mqtt_message{pktid = PktId}, Session = #session{awaiting_ack = Awaiting, + retry_interval = Timeout}) -> TRef = timer(Timeout, {timeout, awaiting_ack, PktId}), - Awaiting1 = maps:put(PktId, {{Retries, Timeout}, TRef}, Awaiting), + Awaiting1 = maps:put(PktId, TRef, Awaiting), Session#session{awaiting_ack = Awaiting1}. acked(PktId, Session = #session{client_id = ClientId, @@ -653,7 +649,7 @@ acked(PktId, Session = #session{client_id = ClientId, {_, Msg} -> emqttd_broker:foreach_hooks('message.acked', [ClientId, Msg]); false -> - lager:error("Session(~s) cannot find acked message: ~p", [PktId]) + lager:error("Session(~s): Cannot find acked message: ~p", [PktId]) end, Session#session{awaiting_ack = maps:remove(PktId, Awaiting), inflight_queue = lists:keydelete(PktId, 1, InflightQ)}. From f57affa2b3942354749cb9e7bda930c7b919568a Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 29 Sep 2015 11:27:48 +0800 Subject: [PATCH 7/9] fix MFArgs --- src/emqttd.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd.erl b/src/emqttd.erl index 21797dd46..b09cd2d32 100644 --- a/src/emqttd.erl +++ b/src/emqttd.erl @@ -90,7 +90,7 @@ open_listener({https, Port, Options}) -> mochiweb:start_http(Port, Options, MFArgs). open_listener(Protocol, Port, Options) -> - MFArgs = {emqttd_client, start_link, env(mqtt)}, + MFArgs = {emqttd_client, start_link, [env(mqtt)]}, esockd:open(Protocol, Port, merge_sockopts(Options) , MFArgs). merge_sockopts(Options) -> From f15e8bc6300c7dfa63cc41bd10b6687098f439fa Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 29 Sep 2015 12:10:55 +0800 Subject: [PATCH 8/9] print ack timout --- rel/files/emqttd.config | 243 ---------------------------------------- src/emqttd_session.erl | 3 +- 2 files changed, 2 insertions(+), 244 deletions(-) delete mode 100644 rel/files/emqttd.config diff --git a/rel/files/emqttd.config b/rel/files/emqttd.config deleted file mode 100644 index 55a8a9455..000000000 --- a/rel/files/emqttd.config +++ /dev/null @@ -1,243 +0,0 @@ -% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- -%% ex: ft=erlang ts=4 sw=4 et -[{kernel, - [{start_timer, true}, - {start_pg2, true} - ]}, - {sasl, [ - {sasl_error_logger, {file, "log/emqttd_sasl.log"}} - ]}, - {ssl, [ - %{versions, ['tlsv1.2', 'tlsv1.1']} - ]}, - {lager, [ - {colored, true}, - {async_threshold, 1000}, - {error_logger_redirect, false}, - {crash_log, "log/emqttd_crash.log"}, - {handlers, [ - {lager_console_backend, info}, - {lager_file_backend, [ - {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]}, - {file, "log/emqttd_info.log"}, - {level, info}, - {size, 104857600}, - {date, "$D0"}, - {count, 30} - ]}, - {lager_file_backend, [ - {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]}, - {file, "log/emqttd_error.log"}, - {level, error}, - {size, 104857600}, - {date, "$D0"}, - {count, 30} - ]} - ]} - ]}, - {esockd, [ - {logger, {lager, info}} - ]}, - {emqttd, [ - %% Authentication and Authorization - {access, [ - %% Authetication. Anonymous Default - {auth, [ - %% Authentication with username, password - %{username, []}, - - %% Authentication with clientid - %{clientid, [{password, no}, {file, "etc/clients.config"}]}, - - %% Authentication with LDAP - % {ldap, [ - % {servers, ["localhost"]}, - % {port, 389}, - % {timeout, 30}, - % {user_dn, "uid=$u,ou=People,dc=example,dc=com"}, - % {ssl, fasle}, - % {sslopts, [ - % {"certfile", "ssl.crt"}, - % {"keyfile", "ssl.key"}]} - % ]}, - - %% Allow all - {anonymous, []} - ]}, - %% ACL config - {acl, [ - %% Internal ACL module - {internal, [{file, "etc/acl.config"}, {nomatch, allow}]} - ]} - ]}, - %% MQTT Protocol Options - {mqtt, [ - %% Packet - {packet, [ - %% Max ClientId Length Allowed - {max_clientid_len, 1024}, - %% Max Packet Size Allowed, 64K default - {max_packet_size, 65536} - ]}, - %% Client - {client, [ - %% Socket is connected, but no 'CONNECT' packet received - {idle_timeout, 10}, %% seconds - %TODO: Network ingoing limit - %{ingoing_rate_limit, '64KB/s'} - %TODO: Reconnet control - ]}, - %% Session - {session, [ - %% Max number of QoS 1 and 2 messages that can be “in flight” at one time. - %% 0 means no limit - {max_inflight, 100}, - - %% Retry interval for redelivering QoS1/2 messages. - {unack_retry_interval, 20}, - - %% Awaiting PUBREL Timeout - {await_rel_timeout, 20}, - - %% Max Packets that Awaiting PUBREL, 0 means no limit - {max_awaiting_rel, 0}, - - %% Statistics Collection Interval(seconds) - {collect_interval, 20}, - - %% Expired after 2 days - {expired_after, 48} - - ]}, - %% Session - {queue, [ - %% Max queue length. enqueued messages when persistent client disconnected, - %% or inflight window is full. - {max_length, 100}, - - %% Low-water mark of queued messsages - {low_watermark, 0.2}, - - %% High-water mark of queued messsages - {high_watermark, 0.6}, - - %% Queue Qos0 messages? - {queue_qos0, true} - ]} - ]}, - %% Broker Options - {broker, [ - %% System interval of publishing broker $SYS messages - {sys_interval, 60}, - - %% Retained messages - {retained, [ - %% Max number of retained messages - {max_message_num, 100000}, - %% Max Payload Size of retained message - {max_playload_size, 65536} - ]}, - %% PubSub - {pubsub, [ - %% default should be scheduler numbers - %% {pool_size, 8} - ]}, - %% Bridge - {bridge, [ - %%TODO: bridge queue size - {max_queue_len, 10000}, - - %% Ping Interval of bridge node - {ping_down_interval, 1} %seconds - ]} - ]}, - %% Modules - {modules, [ - %% Client presence management module. - %% Publish messages when client connected or disconnected - {presence, [{qos, 0}]} - - %% Subscribe topics automatically when client connected - %% {autosub, [{"$Q/client/$c", 0}]} - - %% Rewrite rules - %% {rewrite, [{file, "etc/rewrite.config"}]} - - ]}, - %% Plugins - {plugins, [ - %% Plugin App Library Dir - {plugins_dir, "./plugins"}, - - %% File to store loaded plugin names. - {loaded_file, "./data/loaded_plugins"} - ]}, - %% Listeners - {listeners, [ - {mqtt, 1883, [ - %% Size of acceptor pool - {acceptors, 16}, - %% Maximum number of concurrent clients - {max_clients, 512}, - %% Socket Access Control - {access, [{allow, all}]}, - %% Socket Options - {sockopts, [ - {backlog, 512} - %Set buffer if hight thoughtput - %{recbuf, 4096}, - %{sndbuf, 4096} - %{buffer, 4096}, - ]} - ]}, - {mqtts, 8883, [ - %% Size of acceptor pool - {acceptors, 4}, - %% Maximum number of concurrent clients - {max_clients, 512}, - %% Socket Access Control - {access, [{allow, all}]}, - %% SSL certificate and key files - {ssl, [{certfile, "etc/ssl/ssl.crt"}, - {keyfile, "etc/ssl/ssl.key"}]}, - %% Socket Options - {sockopts, [ - {backlog, 1024} - %{buffer, 4096}, - ]} - ]}, - %% WebSocket over HTTPS Listener - %% {https, 8083, [ - %% %% Size of acceptor pool - %% {acceptors, 4}, - %% %% Maximum number of concurrent clients - %% {max_clients, 512}, - %% %% Socket Access Control - %% {access, [{allow, all}]}, - %% %% SSL certificate and key files - %% {ssl, [{certfile, "etc/ssl/ssl.crt"}, - %% {keyfile, "etc/ssl/ssl.key"}]}, - %% %% Socket Options - %% {sockopts, [ - %% %{buffer, 4096}, - %% {backlog, 1024} - %% ]} - %%]}, - %% HTTP and WebSocket Listener - {http, 8083, [ - %% Size of acceptor pool - {acceptors, 4}, - %% Maximum number of concurrent clients - {max_clients, 64}, - %% Socket Access Control - {access, [{allow, all}]}, - %% Socket Options - {sockopts, [ - {backlog, 1024} - %{buffer, 4096}, - ]} - ]} - ]} - ]} -]. - diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 3db884d55..1d3caa98f 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -220,7 +220,7 @@ unsubscribe(SessPid, Topics) -> %%%============================================================================= init([CleanSess, ClientId, ClientPid]) -> - %process_flag(trap_exit, true), + %% process_flag(trap_exit, true), QEnv = emqttd:env(mqtt, queue), SessEnv = emqttd:env(mqtt, session), Session = #session{ @@ -496,6 +496,7 @@ handle_info({timeout, awaiting_ack, PktId}, Session = #session{client_pid = unde handle_info({timeout, awaiting_ack, PktId}, Session = #session{client_id = ClientId, inflight_queue = InflightQ, awaiting_ack = AwaitingAck}) -> + lager:info("Awaiting Ack Timeout: ~p:", [PktId]), case maps:find(PktId, AwaitingAck) of {ok, _TRef} -> case lists:keyfind(PktId, 1, InflightQ) of From b501ddf43ce642bc28fc68933208ad515e6f09af Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 29 Sep 2015 12:11:29 +0800 Subject: [PATCH 9/9] retry_interval --- rel/files/emqttd.config.development | 13 ++++++------- rel/files/emqttd.config.production | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/rel/files/emqttd.config.development b/rel/files/emqttd.config.development index 3980fba81..2cd50c535 100644 --- a/rel/files/emqttd.config.development +++ b/rel/files/emqttd.config.development @@ -81,6 +81,8 @@ ]}, %% Client {client, [ + %% Socket is connected, but no 'CONNECT' packet received + {idle_timeout, 10} %% seconds %TODO: Network ingoing limit %{ingoing_rate_limit, '64KB/s'} %TODO: Reconnet control @@ -91,20 +93,17 @@ %% 0 means no limit {max_inflight, 100}, - %% Max retries for unack Qos1/2 messages - {unack_retries, 3}, - - %% Retry after 4, 8, 16 seconds - {unack_timeout, 4}, + %% Retry interval for redelivering QoS1/2 messages. + {unack_retry_interval, 20}, %% Awaiting PUBREL Timeout - {await_rel_timeout, 8}, + {await_rel_timeout, 20}, %% Max Packets that Awaiting PUBREL, 0 means no limit {max_awaiting_rel, 0}, %% Statistics Collection Interval(seconds) - {collect_interval, 10}, + {collect_interval, 20}, %% Expired after 2 days {expired_after, 48} diff --git a/rel/files/emqttd.config.production b/rel/files/emqttd.config.production index a0cc7ba45..ff0df40c9 100644 --- a/rel/files/emqttd.config.production +++ b/rel/files/emqttd.config.production @@ -73,6 +73,8 @@ ]}, %% Client {client, [ + %% Socket is connected, but no 'CONNECT' packet received + {idle_timeout, 10} %% seconds %TODO: Network ingoing limit %{ingoing_rate_limit, '64KB/s'} %TODO: Reconnet control @@ -83,14 +85,11 @@ %% 0 means no limit {max_inflight, 100}, - %% Max retries for unack Qos1/2 messages - {unack_retries, 3}, - - %% Retry after 8, 16, 32 seconds - {unack_timeout, 8}, + %% Retry interval for redelivering QoS1/2 messages. + {unack_retry_interval, 30}, %% Awaiting PUBREL Timeout - {await_rel_timeout, 8}, + {await_rel_timeout, 20}, %% Max Packets that Awaiting PUBREL, 0 means no limit {max_awaiting_rel, 0}, @@ -133,7 +132,7 @@ %% PubSub {pubsub, [ %% default should be scheduler numbers - {pool_size, 8} + %% {pool_size, 8} ]}, %% Bridge {bridge, [