fix
This commit is contained in:
parent
359c13924f
commit
3d8fccd0dc
@ -49,7 +49,7 @@ start_link() ->
|
|||||||
{stop, Reason :: term()} | ignore).
|
{stop, Reason :: term()} | ignore).
|
||||||
init([]) ->
|
init([]) ->
|
||||||
%{ok, ServerOpts} = application:get_env(iot, emqx_server),
|
%{ok, ServerOpts} = application:get_env(iot, emqx_server),
|
||||||
{ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
|
% {ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
|
||||||
%{ok, _Props} = emqtt:connect(ConnPid),
|
%{ok, _Props} = emqtt:connect(ConnPid),
|
||||||
|
|
||||||
%SubOpts = [{qos, 1}],
|
%SubOpts = [{qos, 1}],
|
||||||
|
|||||||
@ -52,19 +52,20 @@ init([Host]) ->
|
|||||||
lager:debug("[iot_host] host is: ~p", [Host]),
|
lager:debug("[iot_host] host is: ~p", [Host]),
|
||||||
%% 建立到emqx服务器的连接
|
%% 建立到emqx服务器的连接
|
||||||
{ok, Props} = application:get_env(iot, emqx_server),
|
{ok, Props} = application:get_env(iot, emqx_server),
|
||||||
Host = proplists:get_value(host, Props),
|
EMQXHost = proplists:get_value(host, Props),
|
||||||
Port = proplists:get_value(port, Props, 18080),
|
EMQXPort = proplists:get_value(port, Props, 18080),
|
||||||
Username = proplists:get_value(username, Props),
|
Username = proplists:get_value(username, Props),
|
||||||
Password = proplists:get_value(password, Props),
|
Password = proplists:get_value(password, Props),
|
||||||
RetryInterval = proplists:get_value(retry_interval, Props, 5),
|
RetryInterval = proplists:get_value(retry_interval, Props, 5),
|
||||||
|
Keepalive = proplists:get_value(keepalive, Props, 86400),
|
||||||
Opts = [
|
Opts = [
|
||||||
{host, Host},
|
{host, EMQXHost},
|
||||||
{port, Port},
|
{port, EMQXPort},
|
||||||
{owner, self()},
|
{owner, self()},
|
||||||
{tcp_opts, []},
|
{tcp_opts, []},
|
||||||
{username, Username},
|
{username, Username},
|
||||||
{password, Password},
|
{password, Password},
|
||||||
{keepalive, 'Keepalive'},
|
{keepalive, Keepalive},
|
||||||
{retry_interval, RetryInterval}
|
{retry_interval, RetryInterval}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
%% 目标服务器地址
|
%% 目标服务器地址
|
||||||
{emqx_server, [
|
{emqx_server, [
|
||||||
{host, "103.113.157.7"},
|
{host, {103, 113, 157, 7}},
|
||||||
{port, 18080},
|
{port, 1883},
|
||||||
{tcp_opts, []},
|
{tcp_opts, []},
|
||||||
{username, "test"},
|
{username, "test"},
|
||||||
{password, "test1234"},
|
{password, "test1234"},
|
||||||
{keepalive, 'Keepalive'},
|
{keepalive, 86400},
|
||||||
{retry_interval, 5}
|
{retry_interval, 5}
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user