How to configure grails 3 for mongodb replicaset -


i deploying grails 3 app live server. mongodb instance has been setup in replication mode , tested live box. tested with:

mongo -u uname -authenticationdatabase dbname ip-1.ec2.internal:27017/dbname -p password 

i have used replicaset , connectionstring specified here , here. in both cases behaves though no hosts config have been supplied defaulting localhost. , since that's not set fails. here application.groovy:

mongodb {             replicaset = [ "ip-1.ec2.internal", "ip-12.ec2.internal", "ip-3.ec2.internal"]             host = "ip-1.ec2.internal" //this works of hosts             port = 27017             username = "username"             password = "password"             databasename = "dbname"         } 

i using latest versions:

grailsversion=3.2.8 //it same 3.2.5 gormversion=6.0.9.release gradlewrapperversion=3.4.1 //it same 3.0 

here list of plugins versions:

compile 'org.grails.plugins:mongodb:6.1.0' compile 'org.grails:grails-datastore-rest-client:6.0.9.release' 

and error ran into:

01:22:26.410 - [localhost-startstop-1] info  org.mongodb.driver.cluster - no server chosen  readpreferenceserverselector{readpreference=primary} cluster description clusterdescription{type=unknown, connectionmode=single,  all=[serverdescription{address=127.0.0.1:27017, type=unknown, state=connecting, exception={com.mongodb.mongosecurityexception:  exception authenticating mongocredential{mechanism=null, username='username', source='dbname', password=<hidden>,  mechanismproperties={}}}, caused {com.mongodb.mongocommandexception: command failed error 18:  'authentication failed.' on server 127.0.0.1:27017. full response  { "ok" : 0.0, "code" : 18, "errmsg" : "authentication failed." }}}]}. waiting 30000 ms before timing out 

i have ran out of options now, can please point me out here? thanks.

the connection strings suggested james kleeh solved issue. how used reference example:

mongodb {     url = "mongodb://ip-1.ec2.internal,ip-2.ec2.internal,ip-3.ec2.internal/?replicaset=hostname-of-mongod-instance"     port = 27017     ... } 

Comments