Docker Compose - Mongo Authentication

Hi i installed EMQX 5 using docker but i can’t config the authentication method (mongodb) using enviroment variables in docker compose file.
Example:
According to the configuration manual the mongo server is in this variable: authn-mongodb:standalone.server and according to the enviromental variable rules it should be: EMQX_AUTHN_MONGODB__STANDALONE__SERVER: “mongo:27017”.
But it doesnt work for me.

Enviroment of docker-compose file:

environment:
EMQX_NAME: RedTech_MQTT
EMQX_HOST: 127.0.0.1
TZ: “America/Argentina/Buenos_Aires”

  #DEFAULT DASH PASS
  EMQX_DASHBOARD__DEFAULT_PASSWORD: "${dashpass}"

  #MONGO CONNECTION       
  

  
  EMQX_AUTHN_MONGODB__STANDALONE__MECHANISM: password_based
  EMQX_AUTHN_MONGODB__STANDALONE__BACKEND: mongodb
  EMQX_AUTHN_MONGODB__STANDALONE__ENABLE: true
  EMQX_AUTHN_MONGODB__STANDALONE__PASSWORD_HASH_ALGORITHM: '{name = "plain", salt_position = "disable"}'
  EMQX_AUTHN_MONGODB__STANDALONE__COLLECTION: "emqxauthrules"
  EMQX_AUTHN_MONGODB__STANDALONE__FILTER: '{username = "${username}"}'
  EMQX_AUTHN_MONGODB__STANDALONE__PASSWORD_HASH_FIELD: "password_hash"
  EMQX_AUTHN_MONGODB__STANDALONE__SALT_FIELD: "salt"
  EMQX_AUTHN_MONGODB__STANDALONE__IS_SUPERUSER_FIELD: "is_superuser"
  EMQX_AUTHN_MONGODB__STANDALONE__MONGO_TYPE: single
  EMQX_AUTHN_MONGODB__STANDALONE__SERVER: "mongo:27017"
  EMQX_AUTHN_MONGODB__STANDALONE__POOL_SIZE: 8
  EMQX_AUTHN_MONGODB__STANDALONE__USERNAME: "devuser"
  EMQX_AUTHN_MONGODB__STANDALONE__PASSWORD: "devpassword"
  EMQX_AUTHN_MONGODB__STANDALONE__DATABASE: "iotgl"

Hi. Could you provide error logs in EMQX? So we can know what happened.

Hi I have the same problem for me works if I configure in the web,
I’m using this config:

EMQX_AUTHN_MONGODB_STANDALONE_MECHANISM: password_based
EMQX_AUTHN_MONGODB_STANDALONE_BACKEND: mongodb
EMQX_AUTHN_MONGODB_STANDALONE_ENABLE: true
EMQX_AUTHN_MONGODB_STANDALONE_PASSWORD_HASH_ALGORITHM: '{name = "pbkdf2", pseudorandom_function = "sha512" , iteration_count="4096"}'
EMQX_AUTHN_MONGODB_STANDALONE_COLLECTION: 'users'
EMQX_AUTHN_MONGODB_STANDALONE_FILTER: '{username = "${username}"}'
EMQX_AUTHN_MONGODB_STANDALONE_PASSWORD_HASH_FIELD: 'password'
EMQX_AUTHN_MONGODB_STANDALONE_SALT_FIELD: 'salt'
EMQX_AUTHN_MONGODB_STANDALONE_IS_SUPERUSER_FIELD: 'superuser'
EMQX_AUTHN_MONGODB_STANDALONE_MONGO_TYPE: single
EMQX_AUTHN_MONGODB_STANDALONE_SERVER: 'mongo:27017'
EMQX_AUTHN_MONGODB_STANDALONE_POOL_SIZE: 8
EMQX_AUTHN_MONGODB_STANDALONE_USERNAME: 'admin'
EMQX_AUTHN_MONGODB_STANDALONE_PASSWORD: 'Ne0000000qqv'
EMQX_AUTHN_MONGODB_STANDALONE_DATABASE: 'sys_mqtt'

In the web I put
MongoDB Mode: single
Server: mongo:27017
Database:sys_mqtt
Collection:users
Username:admin
Password:Ne0000000qqv
Pool Size:8
Connect Timeout:20
Password Hash Field:password
Password Hash:pbkdf2
Pseudorandom Function:sha512
Iteration Count:4096
is_superuser Field:superuser

and the log in the terminal:

2023-04-04 14:26:43 2023-04-04T12:26:43.143151+00:00 [error] Supervisor: {<0.2614.0>,ecpool_worker_sup}. Context: start_error. Reason: {connect_failed,{saslContinue,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}. Offender: id={worker,1},pid=undefined.
2023-04-04 14:26:43 2023-04-04T12:26:43.143504+00:00 [error] Supervisor: {<0.2612.0>,ecpool_pool_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,{worker,1},{connect_failed,{saslContinue,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}}}. Offender: id=worker_sup,pid=undefined.
2023-04-04 14:26:43 2023-04-04T12:26:43.143499+00:00 [error] crasher: initial call: mc_topology:init/1, pid: <0.2617.0>, registered_name: [], exit: {{connect_failed,{saslContinue,#{<<"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.2615.0>,<0.2614.0>,<0.2612.0>,ecpool_sup,<0.2532.0>], message_queue_len: 1, messages: [{'$gen_cast',init_seeds}], links: [<0.2615.0>], dictionary: [], trap_exit: false, status: running, heap_size: 376, stack_size: 29, reductions: 325; neighbours:
2023-04-04 14:26:43 2023-04-04T12:26:43.143860+00:00 [error] crasher: initial call: ecpool_worker:init/1, pid: <0.2615.0>, registered_name: [], exit: {{connect_failed,{saslContinue,#{<<"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.2614.0>,<0.2612.0>,ecpool_sup,<0.2532.0>], message_queue_len: 0, messages: [], links: [<0.2616.0>,<0.2617.0>,<0.2614.0>], dictionary: [], trap_exit: true, status: running, heap_size: 376, stack_size: 29, reductions: 352; neighbours:
2023-04-04 14:26:43 2023-04-04T12:26:43.144140+00:00 [error] msg: start_ecpool_error, mfa: emqx_plugin_libs_pool:start_pool/3, line: 48, pool_name: 'emqx_authz_mongodb:1:2', reason: {connect_failed,{saslContinue,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}
2023-04-04 14:26:43 2023-04-04T12:26:43.144284+00:00 [error] Generic server mc_pool_sup terminating. Reason: {connect_failed,{saslContinue,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}. Last message: {'EXIT',<0.2615.0>,{connect_failed,{saslContinue,#{<<"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-04-04 14:26:43 2023-04-04T12:26:43.144407+00:00 [warning] msg: start_resource_failed, mfa: emqx_resource_manager:start_resource/2, line: 524, id: <<"emqx_authz_mongodb:1">>, reason: {start_pool_failed,'emqx_authz_mongodb:1:2',{connect_failed,{saslContinue,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}}
2023-04-04 14:26:43 2023-04-04T12:26:43.144431+00:00 [error] crasher: initial call: supervisor:mc_pool_sup/1, pid: <0.2616.0>, registered_name: mc_pool_sup, exit: {{connect_failed,{saslContinue,#{<<"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.2615.0>,<0.2614.0>,<0.2612.0>,ecpool_sup,<0.2532.0>], message_queue_len: 0, messages: [], links: [], dictionary: [], trap_exit: true, status: running, heap_size: 6772, stack_size: 29, reductions: 10194; neighbours:
2023-04-04 14:26:43 2023-04-04T12:26:43.144739+00:00 [warning] msg: alarm_is_activated, mfa: emqx_alarm:do_actions/3, line: 416, message: <<"resource down: emqx_authz_mongodb:1">>, name: <<"emqx_authz_mongodb:1">>

I try too with an neither

EMQX_AUTHN__MONGODB__STANDALONE__MECHANISM=password_based
EMQX_AUTHN__MONGODB__STANDALONE__BACKEND=mongodb
EMQX_AUTHN__MONGODB__STANDALONE__ENABLE=true
EMQX_AUTHN__MONGODB__STANDALONE__PASSWORD_HASH_ALGORITHM={name = "pbkdf2", pseudorandom_function = "sha512" , iteration_count="4096"}
EMQX_AUTHN__MONGODB__STANDALONE__COLLECTION=users
EMQX_AUTHN__MONGODB__STANDALONE__FILTER={username = "${username}"}
EMQX_AUTHN__MONGODB__STANDALONE__PASSWORD_HASH_FIELD=password
EMQX_AUTHN__MONGODB__STANDALONE__SALT_FIELD=salt
EMQX_AUTHN__MONGODB__STANDALONE__IS_SUPERUSER_FIELD=superuser
EMQX_AUTHN__MONGODB__STANDALONE__MONGO_TYPE=single
EMQX_AUTHN__MONGODB__STANDALONE__SERVER=mongo:27017
EMQX_AUTHN__MONGODB__STANDALONE__POOL_SIZE=8
EMQX_AUTHN__MONGODB__STANDALONE__USERNAME=admin
EMQX_AUTHN__MONGODB__STANDALONE__PASSWORD=NeVrEVppP6K2sqqv
EMQX_AUTHN__MONGODB__STANDALONE__DATABASE=sys_mqtt