Skip to content

Replica set connection issue #374

Open
@ppounder

Description

@ppounder

Hi there,

I'm trying to connect to my replica set within Symfony. I have my config settings as follows as per http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/config.html#connecting-to-a-pool-of-mongodb-servers-on-1-connection

connections:
    default:
        server: 'mongodb://*.*.*.1:27017,*.*.*.2:27017,*.*.*.3:27017'

However I get the error:
Uncaught PHP Exception MongoException: "Cannot run command count(): not master and slaveOk=false"

Let me add a bit of context. Primary is *.*.*.1 and I want to be able to connect via *.*.*.2 or *.*.*.3 if primary goes down and one of the secondaries then become primary. If I go with just the primary mongo server IP address, instead of a comma'd list of my servers, I can connect fine, but that fails if *.*.*.1 goes down and *.*.*.2 becomes primary for example.

Has anyone any suggestions?

Regards
Paul Pounder

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions