简体   繁体   English

可以通过Mongo Shell连接到Heroku中的MongoDB,但不能连接到应用程序

[英]Can connect to MongoDB in Heroku through Mongo shell but not application

I have setup a scala play reactive-mongo application in heroku. 我已经在heroku中设置了一个scala play react-mongo应用程序。 Mongo is provided by mlab in heroku. Mongo由heroku中的mlab提供。 Having a bit of an issue connecting to mongo through the app, connecting through the shell with the same credentials works fine. 通过应用程序连接到mongo时出现问题,使用具有相同凭据的shell连接可以正常工作。 I am using scala play 2.5.1 and reactive 0.11.11 and mongod is 3.0.8. 我正在使用scala播放2.5.1和反应式0.11.11,而mongod是3.0.8。 I think all these versions work together but I get an authentication error at startup: 我认为所有这些版本都可以一起使用,但是在启动时出现验证错误:

2016-04-18T06:59:54.357736+00:00 app[web.1]: [info] application - ReactiveMongoApi starting...
2016-04-18T06:59:54.586309+00:00 app[web.1]: [info] application - ReactiveMongoApi successfully configured with DB 'heroku_0pps6l5f'! Servers:
2016-04-18T06:59:54.586332+00:00 app[web.1]:        [ds051635.mlab.com:51635]
2016-04-18T06:59:55.101238+00:00 heroku[router]: at=info method=POST path="XXXXX" host=YYYYYY request_id=ec31a3df-88a1-4dc4-b195-5d39280db41b fwd="90.200.12.189" dyno=web.1 connect=0ms service=2382ms status=200 bytes=137
2016-04-18T06:59:56.010123+00:00 app[web.1]: [error] r.c.a.MongoDBSystem - authentication failure
2016-04-18T06:59:56.010133+00:00 app[web.1]: reactivemongo.core.commands.FailedAuthentication: BSONCommandError['auth failed'] with original doc {
2016-04-18T06:59:56.010134+00:00 app[web.1]:   ok: BSONDouble(0.0),
2016-04-18T06:59:56.010135+00:00 app[web.1]:   errmsg: "auth failed",
2016-04-18T06:59:56.010135+00:00 app[web.1]:   code: BSONInteger(18)
2016-04-18T06:59:56.010136+00:00 app[web.1]: }

On subsequent inserts I don't get an error but nothing actually gets inserted. 在随后的插入中,我没有收到错误,但实际上没有任何插入。
On retrievals I get the following error: 在检索中,出现以下错误:

2016-04-18T07:05:56.742757+00:00 app[web.1]: Caused by: java.lang.RuntimeException: (,List(ValidationError(List('n' is undefined on object: {"ok":0,"errmsg":"not authorized on heroku_0pps6l5f to execute command { count: \"sightings\" }","code":13}),WrappedArray())))

ReactiveMongo is using MONGODB-CR authentication by default, for backward compatibility purpose (this should be changed for 0.12). 默认情况下,ReactiveMongo使用MONGODB-CR身份验证以实现向后兼容(应将其更改为0.12)。

When using a fresh MongoDB 3.x, the SCRAM-SHA1 authentication is required. 使用全新的MongoDB 3.x时,需要SCRAM-SHA1身份验证。 So make sure this option is enable with ReactiveMongo : authMode=scram-sha1 (in the connection URI). 因此,请确保通过ReactiveMongo启用选项authMode=scram-sha1 (在连接URI中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM