diff --git a/apps/iot/src/iot_mqtt_subscriber.erl b/apps/iot/src/iot_mqtt_subscriber.erl index 7704662..4190cf8 100644 --- a/apps/iot/src/iot_mqtt_subscriber.erl +++ b/apps/iot/src/iot_mqtt_subscriber.erl @@ -76,8 +76,14 @@ init([]) -> case emqtt:start_link(Opts) of {ok, ConnPid} -> lager:debug("[iot_mqtt_subscriber] connect success, pid: ~p", [ConnPid]), - %% 快速启动避免阻塞iot_host_sup的启动 - erlang:start_timer(0, self(), subscribe_ticker), + %% 监听和host相关的全部事件 + {ok, _} = emqtt:connect(ConnPid), + Topics = [ + {<<"$share/nodes_group//server/register">>, 1}, + {<<"$share/nodes_group//host/+/upstream">>, 1} + ], + SubscribeResult = emqtt:subscribe(ConnPid, Topics), + lager:debug("[iot_mqtt_subscriber] subscribe result is: ~p", [SubscribeResult]), {ok, #state{conn_pid = ConnPid}}; ignore -> diff --git a/apps/iot/src/iot_sup.erl b/apps/iot/src/iot_sup.erl index 6316e8b..94b1510 100644 --- a/apps/iot/src/iot_sup.erl +++ b/apps/iot/src/iot_sup.erl @@ -28,14 +28,14 @@ start_link() -> init([]) -> SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, ChildSpecs = [ - #{ - id => 'iot_host_sup', - start => {'iot_host_sup', start_link, []}, - restart => permanent, - shutdown => 2000, - type => supervisor, - modules => ['iot_host_sup'] - }, + %#{ + % id => 'iot_host_sup', + % start => {'iot_host_sup', start_link, []}, + % restart => permanent, + % shutdown => 2000, + % type => supervisor, + % modules => ['iot_host_sup'] + %}, #{ id => 'iot_router_sup',