moped icon indicating copy to clipboard operation
moped copied to clipboard

Moped::Errors::ConnectionFailure: Could not connect to any secondary or primary nodes for replica set

Open AvnerCohen opened this issue 11 years ago • 2 comments

Getting this error when moving from MongoDriver to Moped.

The behaviour is very weird, because I can totally get this to work with MongoDriver, but with moped (no mongoid) something is not working:

MongoDriver Flow:

> mongo_client = Mongo::Connection.new("slave", "27017").db("database_name")
> mongo_client["collection_123"].find_one
=> {"data" = > "Good Data"}

Moped Flow:

> mongo_client = Moped::Session.new(["slave:27017"], database: "database_name")
> session["collection_123"].find().first rescue "Failed"
=> "Failed"
(with Moped::Errors::ConnectionFailure: Could not connect to any secondary or primary nodes for replica set)

However, When I add the master as well (or use master only) this works:

> mongo_client = Moped::Session.new(["master:27017"], database: "database_name")
> session["collection_123"].find().first rescue "Failed"
=> {"data" = > "Good Data"}

> mongo_client = Moped::Session.new(["master:27017", slave:27017"], database: "database_name")
> session["collection_123"].find().first rescue "Failed"
=> {"data" = > "Good Data"}

Am I expecting something weird from Moped?

AvnerCohen avatar Aug 13 '14 08:08 AvnerCohen

Are you still using master/slave setup on MongoDB? and not primary, secondary?

arthurnn avatar Aug 18 '14 14:08 arthurnn

I do. While majority of the stuff is already migrated to ReplicaSets, not all of it had.. As far as I read, this is still a supported setup as per mongodb (although, not recommended one).

AvnerCohen avatar Aug 19 '14 06:08 AvnerCohen