import java.lang.Long
import com.mongodb.async.SingleResultCallback
import com.mongodb.async.client.MongoClients
import reactivemongo.api.MongoConnection.ParsedURI
import reactivemongo.api._
import reactivemongo.core.commands._
import reactivemongo.core.commands.Count
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import play.api.libs.iteratee.Iteratee
import reactivemongo.bson.BSONDocument
import reactivemongo.api.collections.bson.BSONCollection
import scala.util.{Success, Failure}
object Test extends App{
import reactivemongo.api._
import scala.concurrent.ExecutionContext.Implicits.global
val mongoUrl = "mongodb://heroku_app4877663_A:x...@ds033297.mongolab.com:33297/heroku_app4877663"
val databaseName = "heroku_app4877663"
val connectionName = "broadcasts"
println("start reactivemongo")
testReactiveMongo()
println("start reactivejava")
testReactiveJava()
println("done")
def testReactiveMongo() = {
val driver = new MongoDriver
val uri = MongoConnection
.parseURI(mongoUrl)
.get
println(uri.db)
println(uri.hosts)
println(uri.options)
println(uri.authenticate.get.db)
println(uri.authenticate.get.user)
println(uri.authenticate.get.password)
val connection = driver.connection(uri)
val db = connection(databaseName)
val collection: Collection = db(connectionName)
val futureCount = db.command(
Count(collection.name)
)
futureCount.onComplete {
case Success(count) => println("found " + count + " documents")
case Failure(e) => e.printStackTrace()
}
Thread.sleep(10000)
driver.close()
}
def testReactiveJava() = {
// Use a Connection String
val mongoClient = MongoClients.create(mongoUrl)
val database = mongoClient.getDatabase(databaseName)
val collection = database.getCollection(connectionName)
collection.count(new SingleResultCallback[Long] {
override def onResult(count: Long, t: Throwable): Unit = {
if(count != null){
println("found " + count + " documents")
}
if(t != null){
t.printStackTrace()
}
}
})
Thread.sleep(10000)
mongoClient.close()
}
}
output:
[info] - application - ReactiveMongoApi starting...
[warn] - reactivemongo.api.MongoDriver - No mongo-async-driver configuration found
[info] - application - ReactiveMongoApi successfully started with DB 'heroku_4sfp2b40'! Servers:
[ds035533.mongolab.com:35533]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x3dcdcd8c]
[debug] - reactivemongo.core.actors.MongoDBSystem - received a request expecting a response
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) connected
[debug] - reactivemongo.core.actors.MongoDBSystem - NO CHANNEL, error with promise scala.concurrent.impl.Promise$DefaultPromise@3705875f
[debug] - reactivemongo.api.Failover2 - Got an error, retrying... (try #1 is scheduled in 500 ms)
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:635) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:635) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at scala.Option.getOrElse(Option.scala:121) ~[scala-library-2.11.7.jar:na]
at reactivemongo.core.actors.MongoDBSystem$class.pickChannel(actors.scala:635) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at reactivemongo.core.actors.LegacyDBSystem.pickChannel(actors.scala:750) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at reactivemongo.core.actors.MongoDBSystem$$anonfun$4.applyOrElse(actors.scala:304) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170) ~[scala-library-2.11.7.jar:na]
at akka.actor.Actor$class.aroundReceive(Actor.scala:467) ~[akka-actor_2.11.jar:na]
at reactivemongo.core.actors.LegacyDBSystem.aroundReceive(actors.scala:750) ~[reactivemongo_2.11-0.11.7.jar:0.11.7]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) ~[akka-actor_2.11.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:487) ~[akka-actor_2.11.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) ~[akka-actor_2.11.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:220) ~[akka-actor_2.11.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [akka-actor_2.11.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.7.jar:na]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #1036897676 connected. NodeSet status: {{NodeSet None Node[ds035533.mongolab.com:35533: Unknown (1/1 available connections), latency=0], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329317,0,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0xd2d51aa5]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x2f367f3b]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x8295fecb]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0xa7e53f62]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x2ce02455]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x1ee16303]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0xafd573b4]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x66e4b78b]
[trace] - reactivemongo.core.nodeset.ChannelFactory - created a new channel: [id: 0x6679f6fb]
[info] - reactivemongo.core.actors.MongoDBSystem - The node set is now available
[info] - reactivemongo.core.actors.MongoDBSystem - The primary is now available
[debug] - reactivemongo.core.actors.MonitorActor - set: a node is available: ProtocolMetadata(reactivemongo.core.protocol.MongoWireVersion$V24AndBefore$@267d0da6,reactivemongo.core.protocol.MongoWireVersion$V30$@4290c71,16777216,48000000,1000)
[debug] - reactivemongo.core.actors.MonitorActor - set: a primary is available
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #-757785947 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (2/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #-2104099125 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (3/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) connected
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #792100667 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (4/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(81,1329319,1000,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) connected
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #-1478148254 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (5/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #518087427 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (6/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #752886869 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (7/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #1719269115 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (8/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #1726265227 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (9/10 available connections), latency=69], auth=Set() }}
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 1036897676: 45d700f8593a54c2
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.actors.MongoDBSystem - Channel #-1344965708 connected. NodeSet status: {{NodeSet None Node[ds035533-a.mongolab.com:35533: Primary (10/10 available connections), latency=69], auth=Set() }}
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329320,1,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329321,2,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329328,3,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) messageReceived Response(MessageHeader(81,1329327,1001,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(-757785947)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329329,4,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) messageReceived Response(MessageHeader(81,1329333,1002,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(792100667)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329330,5,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329331,6,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) messageReceived Response(MessageHeader(81,1329337,1003,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(-2104099125)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel -757785947: d38ab326a3081417
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) messageReceived Response(MessageHeader(81,1329338,1006,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(518087427)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) messageReceived Response(MessageHeader(81,1329339,1004,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(-1478148254)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) messageReceived Response(MessageHeader(81,1329340,1005,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(752886869)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329332,7,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) messageReceived Response(MessageHeader(81,1329341,1009,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(1719269115)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) messageReceived Response(MessageHeader(81,1329342,1008,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(1726265227)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) messageReceived Response(MessageHeader(81,1329343,1007,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(-1344965708)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329334,8,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(87,1329335,2000,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(401,1329336,9,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=401, cap=401),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 792100667: 58ed6c05ed228c7e
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel -2104099125: e11643dc16e141a9
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel -1478148254: 8f0a52c63f7b77e8
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 518087427: 919d9d5938bbdbad
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 752886869: 921c011e38db20e5
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 1719269115: 44c863e8b9421dc7
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 1726265227: 4ef20fd855cf3d14
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel -1344965708: 5448c50edcfae83c
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 1036897676
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-757785947) messageReceived Response(MessageHeader(87,1329344,2001,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(-757785947)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=792100667) messageReceived Response(MessageHeader(87,1329345,2002,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(792100667)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! -757785947
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 792100667
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=518087427) messageReceived Response(MessageHeader(87,1329346,2005,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(518087427)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 518087427
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=752886869) messageReceived Response(MessageHeader(87,1329347,2006,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(752886869)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 752886869
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1478148254) messageReceived Response(MessageHeader(87,1329348,2004,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(-1478148254)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! -1478148254
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1719269115) messageReceived Response(MessageHeader(87,1329349,2007,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(1719269115)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 1719269115
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(81,1329350,1010,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=81, cap=81),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-2104099125) messageReceived Response(MessageHeader(87,1329351,2003,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(-2104099125)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got nonce for channel 1036897676: debcd39d73c1a502
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=-1344965708) messageReceived Response(MessageHeader(87,1329352,2009,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(-1344965708)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1726265227) messageReceived Response(MessageHeader(87,1329353,2008,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(1726265227)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! -2104099125
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! -1344965708
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 1726265227
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(87,1329354,2010,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=87, cap=87),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - AUTH: got authenticated response! 1036897676
[debug] - reactivemongo.core.actors.MongoDBSystem - received a request expecting a response
[debug] - reactivemongo.core.actors.MongoDBSystem - Sending request expecting response Request(3001,0,Query(0,heroku_4sfp2b40.$cmd,0,1),BufferSequence(DynamicChannelBuffer(ridx=0, widx=42, cap=64),WrappedArray()),reactivemongo.api.ReadPreference$Primary$@51a41fb5,None) by connection Connection([id: 0x3dcdcd8c, /74.76.17.12:36152 => ds035533.mongolab.com/54.144.40.175:35533],Connected,Set(),None) of node ds035533-a.mongolab.com:35533
[trace] - reactivemongo.core.actors.MongoDBSystem - registering awaiting response for requestID 3001, awaitingResponses: Map(3001 -> AwaitingResponse(3001,1036897676,scala.concurrent.impl.Promise$DefaultPromise@2866a82d,false,false))
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is requested!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) a write is complete!
[trace] - reactivemongo.core.protocol.MongoHandler - (channel=1036897676) messageReceived Response(MessageHeader(165,1329366,3001,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=165, cap=165),ResponseInfo(1036897676)) will be send to Actor[akka://reactivemongo/user/Connection-2#1985426663]
[debug] - reactivemongo.core.actors.MongoDBSystem - Got a response from 1036897676! Will give back message=Response(MessageHeader(165,1329366,3001,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=165, cap=165),ResponseInfo(1036897676)) to promise scala.concurrent.impl.Promise$DefaultPromise@2866a82d
[trace] - reactivemongo.core.actors.MongoDBSystem - {3001} [MongoDB26 Write Op response] sending a success!
[trace] - reactivemongo.api.Failover2 - Got an non retryable error, completing with a failure...
reactivemongo.api.commands.bson.DefaultBSONCommandError: CommandError[code=13, errmsg=not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }, doc: {
ok: BSONDouble(0.0),
errmsg: "not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }",
code: BSONInteger(13)
}]
[error] - application -
! @6nk0hk48l - Internal server error, for (GET) [/monitor/list] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[DefaultBSONCommandError: CommandError[code=13, errmsg=not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }, doc: {
ok: BSONDouble(0.0),
errmsg: "not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }",
code: BSONInteger(13)
}]]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.2.jar:2.4.2]
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:191) ~[play_2.11-2.4.2.jar:2.4.2]
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:179) [play_2.11-2.4.2.jar:2.4.2]
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:212) [play_2.11-2.4.2.jar:2.4.2]
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:94) [play_2.11-2.4.2.jar:2.4.2]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [play-netty-server_2.11-2.4.2.jar:2.4.2]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [play-netty-server_2.11-2.4.2.jar:2.4.2]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.7.jar:na]
at scala.util.Failure$$anonfun$recover$1.apply(Try.scala:216) [scala-library-2.11.7.jar:na]
at scala.util.Try$.apply(Try.scala:192) [scala-library-2.11.7.jar:na]
at scala.util.Failure.recover(Try.scala:216) [scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover$1.apply(Future.scala:324) [scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover$1.apply(Future.scala:324) [scala-library-2.11.7.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]
at play.api.libs.iteratee.Execution$trampoline$.executeScheduled(Execution.scala:109) [play-iteratees_2.11-2.4.2.jar:2.4.2]
at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:71) [play-iteratees_2.11-2.4.2.jar:2.4.2]
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [scala-library-2.11.7.jar:na]
at scala.concurrent.Promise$class.complete(Promise.scala:55) [scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153) [scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) [scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) [scala-library-2.11.7.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55) [akka-actor_2.11.jar:na]
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91) [akka-actor_2.11.jar:na]
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91) [akka-actor_2.11.jar:na]
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91) [akka-actor_2.11.jar:na]
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72) [scala-library-2.11.7.jar:na]
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90) [akka-actor_2.11.jar:na]
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [akka-actor_2.11.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [akka-actor_2.11.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.7.jar:na]
Caused by: reactivemongo.api.commands.bson.DefaultBSONCommandError: CommandError[code=13, errmsg=not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }, doc: {
ok: BSONDouble(0.0),
errmsg: "not authorized on heroku_4sfp2b40 to execute command { count: "logs", limit: 0, skip: 0 }",
code: BSONInteger(13)
}]
import reactivemongo.api.MongoConnectionOptions
import reactivemongo.api.ScramSha1Authentication
object Global extends play.api.GlobalSettings {
def driver: reactivemongo.api.MongoDriver = new reactivemongo.api.MongoDriver
val conOpts = MongoConnectionOptions(authMode = ScramSha1Authentication)
play.api.Logger.debug("Connection Options: " + conOpts.toString())
val connection = driver.connection(List("localhost:27017", "dsxxxx.mongolab.com:xxx"), options = conOpts)
...}
We will try to update the demo app deployed on Heroku and using MongoLab, as a live example of the current state of the auth.
Best regards
--
You received this message because you are subscribed to a topic in the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reactivemongo/x3OZ6-hIIXk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reactivemong...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi, The default auth mode is not SCRAM SHA1 for MongoDB3, but for fresh install of MongoDB3. All DB migrated from previous versions are in legacy mode, with no auth change. The protocol version is not sufficient to determine the authMode. Best regards.
The mongodb java driver is switching by server version:Could it be that this legacy mode supports both Native and ScramSha1 but a fresh install will only support ScramSha1?
There is some undergoing refactoring, to have failover during startup, in case of network latency or of unexpected load.
--
When using the indicated snapshot, with the ReactiveMongoApi instance, you can do .connection.database instead of .db .
--
private lazy val db = reactiveMongoApi.connection("heroku_app4877663", FailoverStrategy(50.milliseconds, 20, {n => val w = n * 2; println(w); w}))
[info] play.api.Play - Application started (Dev) 2 4 6 8 10 12 [error] application - ! @6oc3g1i84 - Internal server error, for (GET) [/] -> play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[DetailedDatabaseException: DatabaseException['not authorized for query on heroku_app4877663.broadcasts' (code = 13)]]] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.3.jar:2.4.3] at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:191) ~[play_2.11-2.4.3.jar:2.4.3] at global.ErrorReportingHttpErrorHandler.onServerError(ErrorReportingHttpErrorHandler.scala:30) [classes/:na] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [play-netty-server_2.11-2.4.3.jar:2.4.3] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [play-netty-server_2.11-2.4.3.jar:2.4.3] Caused by: reactivemongo.core.errors.DetailedDatabaseException: DatabaseException['not authorized for query on heroku_app4877663.broadcasts' (code = 13)] at reactivemongo.core.errors.ReactiveMongoException$.apply(errors.scala:32) ~[reactivemongo_2.11-0.12.0-SNAPSHOT.jar:0.12.0-SNAPSHOT] at reactivemongo.core.protocol.Response.error$lzycompute(protocol.scala:269) ~[reactivemongo_2.11-0.12.0-SNAPSHOT.jar:0.12.0-SNAPSHOT] at reactivemongo.core.protocol.Response.error(protocol.scala:264) ~[reactivemongo_2.11-0.12.0-SNAPSHOT.jar:0.12.0-SNAPSHOT] at reactivemongo.core.actors.MongoDBSystem$$anonfun$6.applyOrElse(actors.scala:483) ~[reactivemongo_2.11-0.12.0-SNAPSHOT.jar:0.12.0-SNAPSHOT] at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171) ~[scala-library-2.11.7.jar:na]
Have you tried to pass a FailoverStrategy to the .database function, to adjust according Heroku/MongoLab latency?
--
Same suggestion, try using .database instead of .db .
Best regards
Hi, you can give a try to 0.11.10 .
Good news, thanks for the feedback.
For information, now the test environment of the driver is running one plan with high network latency and appropriate fail over, to validate such case. Best regards
It's not needed as I don't have this 'not authorized on heroku_appXXX to execute command' any more even without it.
But will switch back to that if you think it is related.
In these code, the .database call using FailoverStrategy is comment out? What's happening with?
--
Without the failover at database resolution, the default one is used, considering latency at Heroku ... Moreover, the `.db` will probably be deprecated.