We have a MongoDB Replica set from Ali Cloud. We set up the MongoDB URL as
mongodb://username:password@dds-xxxxx-pub.mongodb.rds.aliyuncs.com:3717,dds-xxxxx-pub.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-xxxxx
When the server starts, ReactiveMongo threw an error:
Invalid node status Primary for dds-2zedbafbdcdae6541787-pub.mongodb.rds.aliyuncs.com:3717 (expected: Unknown); Fallback to Unknown status
I looked through ReactiveMongo's source code but couldn't understand why it is expecting unknown
status?
upSet.updateAll { n =>
if (node.names.contains(n.name) && // the node itself
n.status != node.status) {
// invalidate node status on status conflict
warn(s"Invalid node status ${node.status} for ${node.name} (expected: ${n.status}); Fallback to Unknown status")
n._copy(status = NodeStatus.Unknown)
} else n
}
It works for us after ignoring the replicaSet
option.
http://reactivemongo.org/releases/0.1x/documentation/tutorial/alibaba-apsaradb.html
Finally for ReactiveMongo connection, the replicaSet option can be removed from the URI, and the password placeholder must be replaced with the actual value.
mongodb.uri = "mongodb://root:${APSARADB_PASSWORD}@dds-4e6322c0290348c49176-pub.mongodb.germany.rds.aliyuncs.com:3717/${APSARADB_DBNAME}"