fix: set a timeout for tcp connect
This commit is contained in:
parent
96ca0d9f49
commit
c42c99f94f
|
@ -512,11 +512,12 @@ host_and_port(webhook, #{<<"url">> := Url}) ->
|
||||||
host_and_port(_Unknown, _) ->
|
host_and_port(_Unknown, _) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
|
%% [TODO] remove in EMQX-8588 when resource manager handles things more elegantly
|
||||||
test_connection(undefined) ->
|
test_connection(undefined) ->
|
||||||
%% be friendly, it might fail later on with a 'timeout' error.
|
%% be friendly, it might fail later on with a 'timeout' error.
|
||||||
ok;
|
ok;
|
||||||
test_connection({Host, Port}) ->
|
test_connection({Host, Port}) ->
|
||||||
case gen_tcp:connect(Host, Port, []) of
|
case gen_tcp:connect(Host, Port, [], 5000) of
|
||||||
{ok, TestSocket} -> gen_tcp:close(TestSocket);
|
{ok, TestSocket} -> gen_tcp:close(TestSocket);
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue