我试图通过我在play框架文档中找到的ReactiveMongo依赖项/库将我的play-scala应用程序连接到mongo db。
我在conf文件中添加了如下内容
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"
mongodb.uri = "mongodb://ege:ege123@localhost:27017/smug-studio"但是在运行我的应用程序之后,当我试图通过postman api访问数据库时,它抛出了一个异常,比如
{
"Code": 0,
"ERROR": "MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']"
}在日志里我可以找到这样的东西
[warn] r.c.a.MongoDBSystem - [Supervisor-1/Connection-2] Error while processing getNonce response #1000
[error] r.c.a.MongoDBSystem - [Supervisor-1/Connection-2] Authentication failure
reactivemongo.core.commands.FailedAuthentication: BSONCommandError['Error while processing getNonce response #1000']
at reactivemongo.core.actors.MongoScramSha1Authentication$$anonfun$authReceive$1.$anonfun$applyOrElse$5(MongoScramSha1Authentication.scala:46)
at reactivemongo.core.actors.MongoDBSystem.$anonfun$authenticationResponse$1(MongoDBSystem.scala:1009)
at reactivemongo.core.actors.MongoDBSystem.updateNodeSet(MongoDBSystem.scala:971)
at reactivemongo.core.actors.MongoDBSystem.updateNodeSet$(MongoDBSystem.scala:965)
at reactivemongo.core.actors.StandardDBSystem.updateNodeSet(MongoDBSystem.scala:1337)
at reactivemongo.core.actors.MongoDBSystem.authenticationResponse(MongoDBSystem.scala:1002)
at reactivemongo.core.actors.MongoDBSystem.authenticationResponse$(MongoDBSystem.scala:998)
at reactivemongo.core.actors.StandardDBSystem.authenticationResponse(MongoDBSystem.scala:1337)
at reactivemongo.core.actors.MongoScramSha1Authentication$$anonfun$authReceive$1.$anonfun$applyOrElse$1(MongoScramSha1Authentication.scala:46)
at scala.util.Either.fold(Either.scala:189)
[warn] r.c.a.MongoDBSystem - [Supervisor-1/Connection-2] Error while processing getNonce response #1001
[error] r.c.a.MongoDBSystem - [Supervisor-1/Connection-2] Authentication failure
reactivemongo.core.commands.FailedAuthentication: BSONCommandError['Error while processing getNonce response #1001']
at reactivemongo.core.actors.MongoScramSha1Authentication$$anonfun$authReceive$1.$anonfun$applyOrElse$5(MongoScramSha1Authentication.scala:46)
at reactivemongo.core.actors.MongoDBSystem.$anonfun$authenticationResponse$1(MongoDBSystem.scala:1009)
at reactivemongo.core.actors.MongoDBSystem.updateNodeSet(MongoDBSystem.scala:971)
at reactivemongo.core.actors.MongoDBSystem.updateNodeSet$(MongoDBSystem.scala:965)
at reactivemongo.core.actors.StandardDBSystem.updateNodeSet(MongoDBSystem.scala:1337)
at reactivemongo.core.actors.MongoDBSystem.authenticationResponse(MongoDBSystem.scala:1002)
at reactivemongo.core.actors.MongoDBSystem.authenticationResponse$(MongoDBSystem.scala:998)
at reactivemongo.core.actors.StandardDBSystem.authenticationResponse(MongoDBSystem.scala:1337)
at reactivemongo.core.actors.MongoScramSha1Authentication$$anonfun$authReceive$1.$anonfun$applyOrElse$1(MongoScramSha1Authentication.scala:46)
at scala.util.Either.fold(Either.scala:189)我需要做些什么来解决这个问题?
发布于 2018-07-10 22:26:55
如果你可以在shell上连接到mongo,那么问题可能是你没有在url上正确设置authMode或authMechanism:
mongodb://ege:ege123@localhost:27017/smug-studio?authMechanism=SCRAM-SHA-1或
mongodb://ege:ege123@localhost:27017/smug-studio?authMode=SCRAM-SHA-1http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/connecting/authenticating/
https://stackoverflow.com/questions/51255856
复制相似问题