fix: handle ldap seqrch error
This commit is contained in:
parent
43f799508a
commit
8f94e9684c
|
@ -41,6 +41,7 @@
|
||||||
-export([namespace/0, roots/0, fields/1, desc/1]).
|
-export([namespace/0, roots/0, fields/1, desc/1]).
|
||||||
|
|
||||||
-export([do_get_status/1, get_status_with_poolname/1]).
|
-export([do_get_status/1, get_status_with_poolname/1]).
|
||||||
|
-export([search/2]).
|
||||||
|
|
||||||
-define(LDAP_HOST_OPTIONS, #{
|
-define(LDAP_HOST_OPTIONS, #{
|
||||||
default_port => 389
|
default_port => 389
|
||||||
|
@ -273,6 +274,21 @@ on_query(
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
search(Pid, SearchOptions) ->
|
||||||
|
case eldap:search(Pid, SearchOptions) of
|
||||||
|
{error, ldap_closed} ->
|
||||||
|
%% ldap server closing the socket does not result in
|
||||||
|
%% process restart, so we need to kill it and reconnect
|
||||||
|
_ = exit(Pid, kill),
|
||||||
|
{error, ldap_closed};
|
||||||
|
{error, {gen_tcp_error, timeout}} ->
|
||||||
|
%% kill the process to trigger reconnect
|
||||||
|
_ = exit(Pid, kill),
|
||||||
|
{error, timeout_cause_reconnect};
|
||||||
|
Result ->
|
||||||
|
Result
|
||||||
|
end.
|
||||||
|
|
||||||
do_ldap_query(
|
do_ldap_query(
|
||||||
InstId,
|
InstId,
|
||||||
SearchOptions,
|
SearchOptions,
|
||||||
|
@ -283,7 +299,7 @@ do_ldap_query(
|
||||||
case
|
case
|
||||||
ecpool:pick_and_do(
|
ecpool:pick_and_do(
|
||||||
PoolName,
|
PoolName,
|
||||||
{eldap, search, [SearchOptions]},
|
{?MODULE, search, [SearchOptions]},
|
||||||
handover
|
handover
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
|
@ -319,7 +335,7 @@ do_ldap_query(
|
||||||
?SLOG(
|
?SLOG(
|
||||||
error,
|
error,
|
||||||
LogMeta#{
|
LogMeta#{
|
||||||
msg => "ldap_connector_do_query_failed",
|
msg => "ldap_connector_query_failed",
|
||||||
reason => emqx_utils:redact(Reason)
|
reason => emqx_utils:redact(Reason)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue