Authentication failed handling?
Closed this issue · 7 comments
Hello. Maybe just a question: how shall the authentication failure be handled? Right now I get a badkey
error.
00:38:46.147 [error] Error in process <0.4023.0> on node lorawan@debian with exit value:
{{badkey,<<"payload">>},[{maps,get,[<<"payload">>,#{<<"code">> => 18,
<<"errmsg">> => <<"Authentication failed.">>,<<"ok">> => 0.0}],[]},
{mongodb,scram_step,2,[{file,"/home/.../erlmongo/src/mongodb.erl"},{line,876}]},
{mongodb,connection,3,[{file,"/home/.../erlmongo/src/mongodb.erl"},{line,770}]}]}
Is it the intended behaviour?
Actually yes. Is it a problem?
Not really, I just wondered how the authentication failure shall be correctly handled. Thanks for the response.
Well, it actually is a problem, because the crash is inside the erlmongo application, so it cannot be catched in my code. And the mongodb application gets restarted continuously. How am I supposed to detect the authentication failure?
mongodb:is_connected/1 should return false in this case (with latest update).
Yes, it does, but it also produces an infinite number of error reports due to mongodb application restarts. One restart would be OK, but it keeps restarting forever.
The following escript can be used to reproduce that behaviour:
#!/usr/bin/env escript
%% -*- erlang -*-
main(_Params) ->
application:start(erlmongo),
mongodb:replicaSets(test, 10, ["localhost"], <<"oo">>, undefined),
mongodb:connect(test),
timer:sleep(5000),
io:format("~p~n", [mongodb:is_connected(test)]).
Ok try now. There will be a print for every worker when it fails to authenticate, but will no longer retry in this case.
Thanks a lot. This works.