Play 2.3.5 and ReactiveMongo: MongoError['No primary node is available!']
Asked Answered
B

3

8

I recently upgraded Play to version 2.3.5 and try to use it with ReactiveMongo. However everytime I try to read data from mongoDB an exception occurred. This is my build.sbt:

name := """ReactiveMongoRestExample"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws,
    "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23"
)

This is the stacktrace:

play.api.Application$$anon$1: Execution exception[[PrimaryUnavailableException$: MongoError['No primary node is available!']]] at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.5.jar:2.3.5] at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.5.jar:2.3.5] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.5.jar:2.3.5] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.5.jar:2.3.5] at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.2.jar:na] Caused by: reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!'] at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.(actors.scala) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23] at scala.Option.getOrElse(Option.scala:120) ~[scala-library-2.11.2.jar:na] at reactivemongo.core.actors.MongoDBSystem.pickChannel(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]

MongoDB works fine. I'm able to retrieve data with the commandline tool and IntelliJ.

I pushed the code to github

Maybe someone knows the issue and can help me? That would be awesome

Bluet answered 17/10, 2014 at 12:2 Comment(2)
The problem is fixed. I think it was an issue between reactivemongo and play. I build my application several days later and everything works fine right now.Bluet
I am not convinced this problem is fixed. I run into it if I create to many MongoDriver instances. That's a silly thing to do because it wastes connections and channels and eventually fills up all connections to the mongod server; but, it can happen :)Receptionist
H
0

It's probably unable to start the Mongo server. Go to your /bin folder and run mongo.
You might have too little room available on your temporary folder. try running : mongo --smallfiles

Hyperon answered 10/1, 2015 at 0:5 Comment(0)
M
0

Same issue though updated to Play 2.3.8 with same rx mongo plugin. Mongodb backed works fine under mongo shell as does mongo explorer in intellij idea 14.

Using mongodb.uri in application.conf:

mongodb.uri = "mongodb://pxxxxxxxx:pxxxxxxxx@berne:27017/playdb"

Digging deeper on assumption this is a configuration issue.

Henry

Mciver answered 14/4, 2015 at 16:49 Comment(1)
I stand corrected. I used the wrong server for the uri. It works fine.Mciver
G
0

I had this error because I tried to connect to the db with an unknown user. Creating the user resolved the error.

Grouch answered 16/7, 2018 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.