fix(bridge): mqtt bridge client info `username` & `password`

for non configured `username` and `password`, default values `<<>>` should be
used. emqtt needs the values.
This commit is contained in:
JimMoen 2022-09-16 15:02:03 +08:00
parent 2985810763
commit a660004fa4
1 changed files with 17 additions and 16 deletions

View File

@ -222,20 +222,20 @@ make_forward_confs(undefined) ->
make_forward_confs(FrowardConf) -> make_forward_confs(FrowardConf) ->
FrowardConf. FrowardConf.
basic_config(#{ basic_config(
server := Server, #{
reconnect_interval := ReconnIntv, server := Server,
proto_ver := ProtoVer, reconnect_interval := ReconnIntv,
bridge_mode := BridgeMode, proto_ver := ProtoVer,
username := User, bridge_mode := BridgeMode,
password := Password, clean_start := CleanStart,
clean_start := CleanStart, keepalive := KeepAlive,
keepalive := KeepAlive, retry_interval := RetryIntv,
retry_interval := RetryIntv, max_inflight := MaxInflight,
max_inflight := MaxInflight, replayq := ReplayQ,
replayq := ReplayQ, ssl := #{enable := EnableSsl} = Ssl
ssl := #{enable := EnableSsl} = Ssl } = Conf
}) -> ) ->
#{ #{
replayq => ReplayQ, replayq => ReplayQ,
%% connection opts %% connection opts
@ -251,8 +251,9 @@ basic_config(#{
%% non-standard mqtt connection packets will be filtered out by LB. %% non-standard mqtt connection packets will be filtered out by LB.
%% So let's disable bridge_mode. %% So let's disable bridge_mode.
bridge_mode => BridgeMode, bridge_mode => BridgeMode,
username => User, %% should be iolist for emqtt
password => Password, username => maps:get(username, Conf, <<>>),
password => maps:get(password, Conf, <<>>),
clean_start => CleanStart, clean_start => CleanStart,
keepalive => ms_to_s(KeepAlive), keepalive => ms_to_s(KeepAlive),
retry_interval => RetryIntv, retry_interval => RetryIntv,