MongoLab Scala

Problem

When using casbah to connect to mongo am getting the following exception:

{ "serverUsed" : "xxx.mongolab.com:xxx" , "code" : 18 , "ok" : 0.0 , "errmsg" : "auth fails"}
com.mongodb.CommandFailureException: { "serverUsed" : "xxxx.mongolab.com:xxx" , "code" : 18 , "ok" : 0.0 , "errmsg" : "auth fails"}

When using reactivemongo am getting the following exception:

15:24:50.677 [ForkJoinPool-2-worker-15] ERROR reactivemongo.api.Failover - Got an error, no more attempts to do. Completing with a failure...
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
	at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala) ~[reactivemongo_2.10-0.10.0.jar:0.10.0]

Solution

The problem was with the URI; for MongoLab you have to keep the database name within the uri (even though you would specify it later):

Works (preferable):

It seems that it works better when url is broken into parts/parameters (separting out host, port, username, etc.):

mongoimport --host mongodb1.example.net --port 37017 --username user --password pass --collection contacts --db marketing --file /opt/backups/mdb1-examplenet.json

p.s. depeding on your data format you might need to include option “–jsonArray

Works (alternative):

mongodb://<dbuser>:<dbpassword>@xxxx.mongolab.com:xxx/<database>

Doesn’t Work:

mongodb://<dbuser>:<dbpassword>@xxxx.mongolab.com:xxx

 

 

Other

Changing URI did not fix the problem with reactivemongo; was still getting the following exception:

15:24:50.677 [ForkJoinPool-2-worker-15] ERROR reactivemongo.api.Failover - Got an error, no more attempts to do. Completing with a failure...
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
	at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala) ~[reactivemongo_2.10-0.10.0.jar:0.10.0]

 

Keywords: MongoHQ reactive mongo scala mongodb

mongolab

Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.

Failed: error connecting to db server: no reachable servers

mongoimport

Failed: error unmarshaling bytes on document #0: JSON decoder out of sync – data changing underfoot?

 

About Neil Rubens

see http://ActiveIntelligence.org
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*