fix(http): upgrade ehttpc to 0.1.2 (#4093)
For fix the connection closed by keepalive
This commit is contained in:
parent
472b8bf42e
commit
730d09f874
|
@ -1,5 +1,5 @@
|
||||||
{deps,
|
{deps,
|
||||||
[{ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.1"}}}
|
[{ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.2"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{edoc_opts, [{preprocess, true}]}.
|
{edoc_opts, [{preprocess, true}]}.
|
||||||
|
|
|
@ -41,7 +41,7 @@ web.hook.body.encoding_of_payload_field = plain
|
||||||
## Turn on peer certificate verification
|
## Turn on peer certificate verification
|
||||||
##
|
##
|
||||||
## Value: true | false
|
## Value: true | false
|
||||||
## web.hook.ssl.verify = true
|
## web.hook.ssl.verify = false
|
||||||
|
|
||||||
## Connection process pool size
|
## Connection process pool size
|
||||||
##
|
##
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "web.hook.ssl.verify", "emqx_web_hook.verify", [
|
{mapping, "web.hook.ssl.verify", "emqx_web_hook.verify", [
|
||||||
{default, true},
|
{default, false},
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
{plugins, [rebar3_proper]}.
|
{plugins, [rebar3_proper]}.
|
||||||
|
|
||||||
{deps,
|
{deps,
|
||||||
[{ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.1"}}},
|
[{ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.2"}}}
|
||||||
{emqx_rule_engine, {git, "https://github.com/emqx/emqx-rule-engine"}}
|
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{edoc_opts, [{preprocess, true}]}.
|
{edoc_opts, [{preprocess, true}]}.
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
title => #{en => <<"URL">>,
|
title => #{en => <<"URL">>,
|
||||||
zh => <<"URL"/utf8>>},
|
zh => <<"URL"/utf8>>},
|
||||||
description => #{en => <<"The URL of the server that will receive the Webhook requests.">>,
|
description => #{en => <<"The URL of the server that will receive the Webhook requests.">>,
|
||||||
zh => <<"用于接收 Webhook 请求的服务器的 URL。"/utf8>>}
|
zh => <<"用于接收 Webhook 请求的服务器的 URL。"/utf8>>}
|
||||||
},
|
},
|
||||||
connect_timeout => #{
|
connect_timeout => #{
|
||||||
order => 2,
|
order => 2,
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
default => 5,
|
default => 5,
|
||||||
title => #{en => <<"Connect Timeout">>,
|
title => #{en => <<"Connect Timeout">>,
|
||||||
zh => <<"连接超时时间"/utf8>>},
|
zh => <<"连接超时时间"/utf8>>},
|
||||||
description => #{en => <<"Connect Timeout In Seconds">>,
|
description => #{en => <<"Connect timeout in seconds">>,
|
||||||
zh => <<"连接超时时间,单位秒"/utf8>>}},
|
zh => <<"连接超时时间,单位秒"/utf8>>}},
|
||||||
request_timeout => #{
|
request_timeout => #{
|
||||||
order => 3,
|
order => 3,
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
default => 5,
|
default => 5,
|
||||||
title => #{en => <<"Request Timeout">>,
|
title => #{en => <<"Request Timeout">>,
|
||||||
zh => <<"请求超时时间时间"/utf8>>},
|
zh => <<"请求超时时间时间"/utf8>>},
|
||||||
description => #{en => <<"Request Timeout In Seconds">>,
|
description => #{en => <<"Request timeout in seconds">>,
|
||||||
zh => <<"请求超时时间,单位秒"/utf8>>}},
|
zh => <<"请求超时时间,单位秒"/utf8>>}},
|
||||||
cacertfile => #{
|
cacertfile => #{
|
||||||
order => 4,
|
order => 4,
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
default => <<>>,
|
default => <<>>,
|
||||||
title => #{en => <<"CA Certificate File">>,
|
title => #{en => <<"CA Certificate File">>,
|
||||||
zh => <<"CA 证书文件"/utf8>>},
|
zh => <<"CA 证书文件"/utf8>>},
|
||||||
description => #{en => <<"CA Certificate File.">>,
|
description => #{en => <<"CA certificate file.">>,
|
||||||
zh => <<"CA 证书文件。"/utf8>>}
|
zh => <<"CA 证书文件。"/utf8>>}
|
||||||
},
|
},
|
||||||
certfile => #{
|
certfile => #{
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
default => <<>>,
|
default => <<>>,
|
||||||
title => #{en => <<"Certificate File">>,
|
title => #{en => <<"Certificate File">>,
|
||||||
zh => <<"证书文件"/utf8>>},
|
zh => <<"证书文件"/utf8>>},
|
||||||
description => #{en => <<"Certificate File.">>,
|
description => #{en => <<"Certificate file.">>,
|
||||||
zh => <<"证书文件。"/utf8>>}
|
zh => <<"证书文件。"/utf8>>}
|
||||||
},
|
},
|
||||||
keyfile => #{
|
keyfile => #{
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
verify => #{
|
verify => #{
|
||||||
order => 7,
|
order => 7,
|
||||||
type => boolean,
|
type => boolean,
|
||||||
default => true,
|
default => false,
|
||||||
title => #{en => <<"Verify">>,
|
title => #{en => <<"Verify">>,
|
||||||
zh => <<"Verify"/utf8>>},
|
zh => <<"Verify"/utf8>>},
|
||||||
description => #{en => <<"Turn on peer certificate verification.">>,
|
description => #{en => <<"Turn on peer certificate verification.">>,
|
||||||
|
@ -92,8 +92,8 @@
|
||||||
default => 32,
|
default => 32,
|
||||||
title => #{en => <<"Pool Size">>,
|
title => #{en => <<"Pool Size">>,
|
||||||
zh => <<"连接池大小"/utf8>>},
|
zh => <<"连接池大小"/utf8>>},
|
||||||
description => #{en => <<"Pool Size for HTTP Server.">>,
|
description => #{en => <<"Pool size for HTTP server.">>,
|
||||||
zh => <<"HTTP Server 连接池大小。"/utf8>>}
|
zh => <<"HTTP server 连接池大小。"/utf8>>}
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
method => #{
|
method => #{
|
||||||
order => 1,
|
order => 1,
|
||||||
type => string,
|
type => string,
|
||||||
enum => [<<"POST">>,<<"DELETE">>,<<"PUT">>,<<"GET">>],
|
enum => [<<"POST">>, <<"DELETE">>, <<"PUT">>, <<"GET">>],
|
||||||
default => <<"POST">>,
|
default => <<"POST">>,
|
||||||
title => #{en => <<"Method">>,
|
title => #{en => <<"Method">>,
|
||||||
zh => <<"Method"/utf8>>},
|
zh => <<"Method"/utf8>>},
|
||||||
|
@ -263,15 +263,15 @@ on_action_data_to_webserver(Selected, _Envs =
|
||||||
Req = create_req(Method, NPath, Headers, NBody),
|
Req = create_req(Method, NPath, Headers, NBody),
|
||||||
case ehttpc:request(ehttpc_pool:pick_worker(Pool, ClientID), Method, Req, RequestTimeout) of
|
case ehttpc:request(ehttpc_pool:pick_worker(Pool, ClientID), Method, Req, RequestTimeout) of
|
||||||
{ok, StatusCode, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
{ok, StatusCode, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
||||||
ok;
|
emqx_rule_metrics:inc_actions_success(Id);
|
||||||
{ok, StatusCode, _, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
{ok, StatusCode, _, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
||||||
ok;
|
emqx_rule_metrics:inc_actions_success(Id);
|
||||||
{ok, StatusCode, _} ->
|
{ok, StatusCode, _} ->
|
||||||
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
||||||
ok;
|
emqx_rule_metrics:inc_actions_error(Id);
|
||||||
{ok, StatusCode, _, _} ->
|
{ok, StatusCode, _, _} ->
|
||||||
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
||||||
ok;
|
emqx_rule_metrics:inc_actions_error(Id);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?LOG(error, "[WebHook Action] HTTP request error: ~p", [Reason]),
|
?LOG(error, "[WebHook Action] HTTP request error: ~p", [Reason]),
|
||||||
emqx_rule_metrics:inc_actions_error(Id)
|
emqx_rule_metrics:inc_actions_error(Id)
|
||||||
|
@ -357,7 +357,7 @@ pool_opts(Params = #{<<"url">> := URL}) ->
|
||||||
(_) ->
|
(_) ->
|
||||||
true
|
true
|
||||||
end, [{keyfile, KeyFile}, {certfile, CertFile}, {cacertfile, CACertFile}]),
|
end, [{keyfile, KeyFile}, {certfile, CertFile}, {cacertfile, CACertFile}]),
|
||||||
TlsVers = ['tlsv1.2','tlsv1.1',tlsv1],
|
TlsVers = ['tlsv1.2', 'tlsv1.1', tlsv1],
|
||||||
NTLSOpts = [{verify, VerifyType},
|
NTLSOpts = [{verify, VerifyType},
|
||||||
{versions, TlsVers},
|
{versions, TlsVers},
|
||||||
{ciphers, lists:foldl(fun(TlsVer, Ciphers) ->
|
{ciphers, lists:foldl(fun(TlsVer, Ciphers) ->
|
||||||
|
|
|
@ -52,10 +52,10 @@ translate_env() ->
|
||||||
{ok, URL} = application:get_env(?APP, url),
|
{ok, URL} = application:get_env(?APP, url),
|
||||||
#{host := Host0,
|
#{host := Host0,
|
||||||
path := Path0,
|
path := Path0,
|
||||||
scheme := Scheme} = URIMap = uri_string:parse(add_default_scheme(URL)),
|
scheme := Scheme} = URIMap = uri_string:parse(add_default_scheme(uri_string:normalize(URL))),
|
||||||
Port = maps:get(port, URIMap, case Scheme of
|
Port = maps:get(port, URIMap, case Scheme of
|
||||||
"https" -> 443;
|
"https" -> 443;
|
||||||
_ -> 80
|
"http" -> 80
|
||||||
end),
|
end),
|
||||||
Path = path(Path0),
|
Path = path(Path0),
|
||||||
{Inet, Host} = parse_host(Host0),
|
{Inet, Host} = parse_host(Host0),
|
||||||
|
|
Loading…
Reference in New Issue