Auto-pull-request-by-2019-02-19 (#2232)
* Update Copyright to 2019 (#2191) * Disable bridges by default (#2189) * Fix warning logger args emqx#2195 * Ambiguity elimination (#2217) * Fix emqx_ws_connection: prevent crashes on pong (#2210) * Issue#2184 (#2194) * Delete dep-vsn-check * Format app.src
This commit is contained in:
parent
11d9aaa002
commit
44d3eff094
23
Makefile
23
Makefile
|
@ -113,26 +113,3 @@ rebar-clean:
|
||||||
distclean::
|
distclean::
|
||||||
@rm -rf _build cover deps logs log data
|
@rm -rf _build cover deps logs log data
|
||||||
@rm -f rebar.lock compile_commands.json cuttlefish
|
@rm -f rebar.lock compile_commands.json cuttlefish
|
||||||
|
|
||||||
## Below are for version consistency check during erlang.mk and rebar3 dual mode support
|
|
||||||
none=
|
|
||||||
space = $(none) $(none)
|
|
||||||
comma = ,
|
|
||||||
quote = \"
|
|
||||||
curly_l = "{"
|
|
||||||
curly_r = "}"
|
|
||||||
dep-versions = [$(foreach dep,$(DEPS) $(BUILD_DEPS),$(curly_l)$(dep),$(quote)$(word $(words $(dep_$(dep))),$(dep_$(dep)))$(quote)$(curly_r)$(comma))[]]
|
|
||||||
|
|
||||||
.PHONY: dep-vsn-check
|
|
||||||
dep-vsn-check:
|
|
||||||
$(verbose) erl -noshell -eval \
|
|
||||||
"MkVsns = lists:sort(lists:flatten($(dep-versions))), \
|
|
||||||
{ok, Conf} = file:consult('rebar.config'), \
|
|
||||||
{_, Deps1} = lists:keyfind(deps, 1, Conf), \
|
|
||||||
{_, Deps2} = lists:keyfind(github_emqx_deps, 1, Conf), \
|
|
||||||
F = fun({N, V}) when is_list(V) -> {N, V}; ({N, {git, _, {branch, V}}}) -> {N, V} end, \
|
|
||||||
RebarVsns = lists:sort(lists:map(F, Deps1 ++ Deps2)), \
|
|
||||||
case {RebarVsns -- MkVsns, MkVsns -- RebarVsns} of \
|
|
||||||
{[], []} -> halt(0); \
|
|
||||||
{Rebar, Mk} -> erlang:error({deps_version_discrepancy, [{rebar, Rebar}, {mk, Mk}]}) \
|
|
||||||
end."
|
|
||||||
|
|
|
@ -286,32 +286,32 @@ rpc.tcp_client_port = 5369
|
||||||
## RCP Client connect timeout.
|
## RCP Client connect timeout.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.connect_timeout = 5000
|
rpc.connect_timeout = 5s
|
||||||
|
|
||||||
## TCP send timeout of RPC client and server.
|
## TCP send timeout of RPC client and server.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.send_timeout = 5000
|
rpc.send_timeout = 5s
|
||||||
|
|
||||||
## Authentication timeout
|
## Authentication timeout
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.authentication_timeout = 5000
|
rpc.authentication_timeout = 5s
|
||||||
|
|
||||||
## Default receive timeout for call() functions
|
## Default receive timeout for call() functions
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.call_receive_timeout = 15000
|
rpc.call_receive_timeout = 15s
|
||||||
|
|
||||||
## Socket idle keepalive.
|
## Socket idle keepalive.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.socket_keepalive_idle = 900
|
rpc.socket_keepalive_idle = 900s
|
||||||
|
|
||||||
## TCP Keepalive probes interval.
|
## TCP Keepalive probes interval.
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Seconds
|
||||||
rpc.socket_keepalive_interval = 75
|
rpc.socket_keepalive_interval = 75s
|
||||||
|
|
||||||
## Probes lost to close the connection
|
## Probes lost to close the connection
|
||||||
##
|
##
|
||||||
|
@ -947,7 +947,7 @@ listener.tcp.internal.send_timeout = 5s
|
||||||
## See: listener.tcp.$name.send_timeout_close
|
## See: listener.tcp.$name.send_timeout_close
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
listener.tcp.external.send_timeout_close = on
|
listener.tcp.internal.send_timeout_close = on
|
||||||
|
|
||||||
## The TCP receive buffer(os kernel) for internal MQTT connections.
|
## The TCP receive buffer(os kernel) for internal MQTT connections.
|
||||||
##
|
##
|
||||||
|
@ -1596,29 +1596,29 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G
|
||||||
## Value: enum
|
## Value: enum
|
||||||
## manual
|
## manual
|
||||||
## auto
|
## auto
|
||||||
bridge.aws.start_type = manual
|
## bridge.aws.start_type = manual
|
||||||
|
|
||||||
## Bridge reconnect time.
|
## Bridge reconnect time.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
## Default: 30 seconds
|
## Default: 30 seconds
|
||||||
bridge.aws.reconnect_interval = 30s
|
## bridge.aws.reconnect_interval = 30s
|
||||||
|
|
||||||
## Retry interval for bridge QoS1 message delivering.
|
## Retry interval for bridge QoS1 message delivering.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
bridge.aws.retry_interval = 20s
|
## bridge.aws.retry_interval = 20s
|
||||||
|
|
||||||
## Inflight size.
|
## Inflight size.
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Integer
|
||||||
bridge.aws.max_inflight = 32
|
## bridge.aws.max_inflight = 32
|
||||||
|
|
||||||
## Bridge address: node name for local bridge, host:port for remote.
|
## Bridge address: node name for local bridge, host:port for remote.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
## Example: emqx@127.0.0.1, 127.0.0.1:1883
|
## Example: emqx@127.0.0.1, 127.0.0.1:1883
|
||||||
bridge.aws.address = 127.0.0.1:1883
|
## bridge.aws.address = 127.0.0.1:1883
|
||||||
|
|
||||||
## Protocol version of the bridge.
|
## Protocol version of the bridge.
|
||||||
##
|
##
|
||||||
|
@ -1626,12 +1626,12 @@ bridge.aws.address = 127.0.0.1:1883
|
||||||
## - mqttv5
|
## - mqttv5
|
||||||
## - mqttv4
|
## - mqttv4
|
||||||
## - mqttv3
|
## - mqttv3
|
||||||
bridge.aws.proto_ver = mqttv4
|
## bridge.aws.proto_ver = mqttv4
|
||||||
|
|
||||||
## The ClientId of a remote bridge.
|
## The ClientId of a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.client_id = bridge_aws
|
## bridge.aws.client_id = bridge_aws
|
||||||
|
|
||||||
## The Clean start flag of a remote bridge.
|
## The Clean start flag of a remote bridge.
|
||||||
##
|
##
|
||||||
|
@ -1645,62 +1645,62 @@ bridge.aws.client_id = bridge_aws
|
||||||
## The username for a remote bridge.
|
## The username for a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.username = user
|
## bridge.aws.username = user
|
||||||
|
|
||||||
## The password for a remote bridge.
|
## The password for a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.password = passwd
|
## bridge.aws.password = passwd
|
||||||
|
|
||||||
## Mountpoint of the bridge.
|
## Mountpoint of the bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.mountpoint = bridge/aws/${node}/
|
## bridge.aws.mountpoint = bridge/aws/${node}/
|
||||||
|
|
||||||
## Ping interval of a down bridge.
|
## Ping interval of a down bridge.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
## Default: 10 seconds
|
## Default: 10 seconds
|
||||||
bridge.aws.keepalive = 60s
|
## bridge.aws.keepalive = 60s
|
||||||
|
|
||||||
## Forward message topics
|
## Forward message topics
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
## Example: topic1/#,topic2/#
|
## Example: topic1/#,topic2/#
|
||||||
bridge.aws.forwards = topic1/#,topic2/#
|
## bridge.aws.forwards = topic1/#,topic2/#
|
||||||
|
|
||||||
## Subscriptions of the bridge topic.
|
## Subscriptions of the bridge topic.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.subscription.1.topic = cmd/topic1
|
## bridge.aws.subscription.1.topic = cmd/topic1
|
||||||
|
|
||||||
## Subscriptions of the bridge qos.
|
## Subscriptions of the bridge qos.
|
||||||
##
|
##
|
||||||
## Value: Number
|
## Value: Number
|
||||||
bridge.aws.subscription.1.qos = 1
|
## bridge.aws.subscription.1.qos = 1
|
||||||
|
|
||||||
## Subscriptions of the bridge topic.
|
## Subscriptions of the bridge topic.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.subscription.2.topic = cmd/topic2
|
## bridge.aws.subscription.2.topic = cmd/topic2
|
||||||
|
|
||||||
## Subscriptions of the bridge qos.
|
## Subscriptions of the bridge qos.
|
||||||
##
|
##
|
||||||
## Value: Number
|
## Value: Number
|
||||||
bridge.aws.subscription.2.qos = 1
|
## bridge.aws.subscription.2.qos = 1
|
||||||
|
|
||||||
## If enabled, queue would be written into disk more quickly.
|
## If enabled, queue would be written into disk more quickly.
|
||||||
## However, If disabled, some message would be dropped in
|
## However, If disabled, some message would be dropped in
|
||||||
## the situation emqx crashed.
|
## the situation emqx crashed.
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
bridge.aws.queue.mem_cache = on
|
## bridge.aws.queue.mem_cache = on
|
||||||
|
|
||||||
## Batch size for buffer queue stored
|
## Batch size for buffer queue stored
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Integer
|
||||||
## default: 1000
|
## default: 1000
|
||||||
bridge.aws.queue.batch_size = 1000
|
## bridge.aws.queue.batch_size = 1000
|
||||||
|
|
||||||
## Base directory for replayq to store messages on disk
|
## Base directory for replayq to store messages on disk
|
||||||
## If this config entry is missing or set to undefined,
|
## If this config entry is missing or set to undefined,
|
||||||
|
@ -1709,18 +1709,18 @@ bridge.aws.queue.batch_size = 1000
|
||||||
## this config entry would have no effect on mqueue
|
## this config entry would have no effect on mqueue
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/
|
## bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/
|
||||||
|
|
||||||
## Replayq segment size
|
## Replayq segment size
|
||||||
##
|
##
|
||||||
## Value: Bytesize
|
## Value: Bytesize
|
||||||
|
|
||||||
bridge.aws.queue.replayq_seg_bytes = 10MB
|
## bridge.aws.queue.replayq_seg_bytes = 10MB
|
||||||
|
|
||||||
## Bribge to remote server via SSL.
|
## Bribge to remote server via SSL.
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
bridge.aws.ssl = off
|
## bridge.aws.ssl = off
|
||||||
|
|
||||||
## PEM-encoded CA certificates of the bridge.
|
## PEM-encoded CA certificates of the bridge.
|
||||||
##
|
##
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
-define(NOTICE(Format, Args), ?LOG(notice, Format, Args)).
|
-define(NOTICE(Format, Args), ?LOG(notice, Format, Args)).
|
||||||
|
|
||||||
-define(WARN(Format), ?LOG(warning, Format, [])).
|
-define(WARN(Format), ?LOG(warning, Format, [])).
|
||||||
-define(WARN(Format, Args), ?LOG(warning, Format, [])).
|
-define(WARN(Format, Args), ?LOG(warning, Format, Args)).
|
||||||
|
|
||||||
-define(ERROR(Format), ?LOG(error, Format, [])).
|
-define(ERROR(Format), ?LOG(error, Format, [])).
|
||||||
-define(ERROR(Format, Args), ?LOG(error, Format, Args)).
|
-define(ERROR(Format, Args), ?LOG(error, Format, Args)).
|
||||||
|
|
|
@ -324,38 +324,38 @@ end}.
|
||||||
|
|
||||||
%% Client connect timeout
|
%% Client connect timeout
|
||||||
{mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [
|
{mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [
|
||||||
{default, 5000},
|
{default, "5s"},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Client and Server send timeout
|
%% Client and Server send timeout
|
||||||
{mapping, "rpc.send_timeout", "gen_rpc.send_timeout", [
|
{mapping, "rpc.send_timeout", "gen_rpc.send_timeout", [
|
||||||
{default, 5000},
|
{default, 5000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Authentication timeout
|
%% Authentication timeout
|
||||||
{mapping, "rpc.authentication_timeout", "gen_rpc.authentication_timeout", [
|
{mapping, "rpc.authentication_timeout", "gen_rpc.authentication_timeout", [
|
||||||
{default, 5000},
|
{default, 5000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Default receive timeout for call() functions
|
%% Default receive timeout for call() functions
|
||||||
{mapping, "rpc.call_receive_timeout", "gen_rpc.call_receive_timeout", [
|
{mapping, "rpc.call_receive_timeout", "gen_rpc.call_receive_timeout", [
|
||||||
{default, 15000},
|
{default, 15000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Socket keepalive configuration
|
%% Socket keepalive configuration
|
||||||
{mapping, "rpc.socket_keepalive_idle", "gen_rpc.socket_keepalive_idle", [
|
{mapping, "rpc.socket_keepalive_idle", "gen_rpc.socket_keepalive_idle", [
|
||||||
{default, 7200},
|
{default, 7200},
|
||||||
{datatype, integer}
|
{datatype, {duration, s}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Seconds between probes
|
%% Seconds between probes
|
||||||
{mapping, "rpc.socket_keepalive_interval", "gen_rpc.socket_keepalive_interval", [
|
{mapping, "rpc.socket_keepalive_interval", "gen_rpc.socket_keepalive_interval", [
|
||||||
{default, 75},
|
{default, 75},
|
||||||
{datatype, integer}
|
{datatype, {duration, s}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Probes lost to close the connection
|
%% Probes lost to close the connection
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
CONFIG0 = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
|
CONFIG0 = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
|
||||||
"--depth 1" ->
|
"--depth 1" ->
|
||||||
CONFIG;
|
CONFIG;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
{vsn,"git"},
|
{vsn,"git"},
|
||||||
{modules,[]},
|
{modules,[]},
|
||||||
{registered,[emqx_sup]},
|
{registered,[emqx_sup]},
|
||||||
{applications,[kernel,stdlib,jsx,gproc,gen_rpc,esockd,cowboy,replayq]},
|
{applications,[kernel,stdlib,jsx,gproc,gen_rpc,esockd,cowboy,
|
||||||
|
replayq]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
{mod,{emqx_app,[]}},
|
{mod,{emqx_app,[]}},
|
||||||
{maintainers,["Feng Lee <feng@emqx.io>"]},
|
{maintainers,["Feng Lee <feng@emqx.io>"]},
|
||||||
|
|
|
@ -189,7 +189,15 @@ websocket_handle({binary, Data}, State = #state{parser_state = ParserState,
|
||||||
_:Error ->
|
_:Error ->
|
||||||
?LOG(error, "Frame error:~p~nFrame data: ~p", [Error, Data]),
|
?LOG(error, "Frame error:~p~nFrame data: ~p", [Error, Data]),
|
||||||
shutdown(parse_error, State)
|
shutdown(parse_error, State)
|
||||||
end.
|
end;
|
||||||
|
%% Pings should be replied with pongs, cowboy does it automatically
|
||||||
|
%% Pongs can be safely ignored. Clause here simply prevents crash.
|
||||||
|
websocket_handle(Frame, State)
|
||||||
|
when Frame =:= ping; Frame =:= pong ->
|
||||||
|
{ok, ensure_stats_timer(State)};
|
||||||
|
websocket_handle({FrameType, _}, State)
|
||||||
|
when FrameType =:= ping; FrameType =:= pong ->
|
||||||
|
{ok, ensure_stats_timer(State)}.
|
||||||
|
|
||||||
websocket_info({call, From, info}, State) ->
|
websocket_info({call, From, info}, State) ->
|
||||||
gen_server:reply(From, info(State)),
|
gen_server:reply(From, info(State)),
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
run_setup_steps() ->
|
run_setup_steps() ->
|
||||||
NewConfig = generate_config(),
|
NewConfig = generate_config(),
|
||||||
lists:foreach(fun set_app_env/1, NewConfig),
|
lists:foreach(fun set_app_env/1, NewConfig),
|
||||||
|
set_bridge_env(),
|
||||||
application:ensure_all_started(?APP).
|
application:ensure_all_started(?APP).
|
||||||
|
|
||||||
run_teardown_steps() ->
|
run_teardown_steps() ->
|
||||||
|
@ -88,6 +89,10 @@ set_app_env({App, Lists}) ->
|
||||||
application:set_env(App, Par, Var)
|
application:set_env(App, Par, Var)
|
||||||
end, Lists).
|
end, Lists).
|
||||||
|
|
||||||
|
set_bridge_env() ->
|
||||||
|
BridgeEnvs = bridge_conf(),
|
||||||
|
application:set_env(?APP, bridges, BridgeEnvs).
|
||||||
|
|
||||||
change_opts(SslType) ->
|
change_opts(SslType) ->
|
||||||
{ok, Listeners} = application:get_env(?APP, listeners),
|
{ok, Listeners} = application:get_env(?APP, listeners),
|
||||||
NewListeners =
|
NewListeners =
|
||||||
|
@ -149,3 +154,26 @@ flush(Msgs) ->
|
||||||
after
|
after
|
||||||
0 -> lists:reverse(Msgs)
|
0 -> lists:reverse(Msgs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
bridge_conf() ->
|
||||||
|
[{aws,
|
||||||
|
[{username,"user"},
|
||||||
|
{address,"127.0.0.1:1883"},
|
||||||
|
{clean_start,true},
|
||||||
|
{client_id,"bridge_aws"},
|
||||||
|
{forwards,["topic1/#","topic2/#"]},
|
||||||
|
{keepalive,60000},
|
||||||
|
{max_inflight,32},
|
||||||
|
{mountpoint,"bridge/aws/${node}/"},
|
||||||
|
{password,"passwd"},
|
||||||
|
{proto_ver,mqttv4},
|
||||||
|
{queue,
|
||||||
|
#{batch_size => 1000,mem_cache => true,
|
||||||
|
replayq_dir => "data/emqx_aws_bridge/",
|
||||||
|
replayq_seg_bytes => 10485760}},
|
||||||
|
{reconnect_interval,30000},
|
||||||
|
{retry_interval,20000},
|
||||||
|
{ssl,false},
|
||||||
|
{ssl_opts,[{versions,[tlsv1,'tlsv1.1','tlsv1.2']}]},
|
||||||
|
{start_type,manual},
|
||||||
|
{subscriptions,[{"cmd/topic1",1},{"cmd/topic2",1}]}]}].
|
Loading…
Reference in New Issue