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