Emqx5.0.26 Mongodb认证

环境

  • EMQX 版本:5.0.26
  • 操作系统版本:Ubuntu 18.04 arm64

重现此问题的步骤

  1. 配置并启动mongodb4.2,创建mqtt数据库,增加用户 mqtt

    2.编辑配置文件,启动emqx(以下为配置文件片段)
  2. 登录dashboard查看客户端认证

预期行为

连接成功

实际行为

控制台显示:


emqx日志文件报错:
2023-06-21T17:02:03.576492+08:00 [error] crasher: initial call: ecpool_worker:init/1, pid: <0.3894.0>, registered_name: [], exit: {{connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}},[{gen_server,init_it,6,[{file,“gen_server.erl”},{line,407}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [<0.3893.0>,<0.3891.0>,ecpool_sup,<0.2525.0>], message_queue_len: 0, messages: [], links: [<0.3895.0>,<0.3896.0>,<0.3893.0>], dictionary: [], trap_exit: true, status: running, heap_size: 610, stack_size: 28, reductions: 359; neighbours:
2023-06-21T17:02:03.576952+08:00 [error] msg: start_ecpool_error, mfa: emqx_resource_pool:start/3, line: 49, pool_name: <<“emqx_authn_mongodb:1”>>, reason: {connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}}
2023-06-21T17:02:03.577077+08:00 [error] Generic server mc_pool_sup terminating. Reason: {connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}}. Last message: {‘EXIT’,<0.3894.0>,{connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}}}. State: {state,{local,mc_pool_sup},simple_one_for_one,{[worker_pool],#{worker_pool => {child,undefined,worker_pool,{poolboy,start_link,[]},transient,false,5000,worker,[poolboy]}}},{maps,#{}},1000,3600,[],0,never,mc_pool_sup,[]}.
2023-06-21T17:02:03.577214+08:00 [warning] msg: start_resource_failed, mfa: emqx_resource_manager:start_resource/2, line: 489, id: <<“emqx_authn_mongodb:1”>>, reason: {start_pool_failed,<<“emqx_authn_mongodb:1”>>,{connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}}}
2023-06-21T17:02:03.577421+08:00 [error] crasher: initial call: supervisor:mc_pool_sup/1, pid: <0.3895.0>, registered_name: mc_pool_sup, exit: {{connect_failed,{saslStart,#{<<“code”>> => 18,<<“codeName”>> => <<“AuthenticationFailed”>>,<<“errmsg”>> => <<“Authentication failed.”>>}}},[{gen_server,decode_msg,9,[{file,“gen_server.erl”},{line,481}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [<0.3894.0>,<0.3893.0>,<0.3891.0>,ecpool_sup,<0.2525.0>], message_queue_len: 0, messages: [], links: [], dictionary: [], trap_exit: true, status: running, heap_size: 6772, stack_size: 28, reductions: 8472; neighbours:
2023-06-21T17:02:03.577547+08:00 [warning] msg: alarm_is_activated, mfa: emqx_alarm:do_actions/3, line: 418, message: <<“resource down: {start_pool_failed,<<"emqx_authn_mongodb:1">>,{connect_failed,{saslStart,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}}”>>, name: <<“emqx_authn_mongodb:1”>>

-

第一次使用emqx,未能理解日志文件中的报错具体是哪里不太对,恳请指点

看起来是 EMQX 与 mongodb 连不上,原因是认证失败。

#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}