Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:15:48+00:00 2026-06-10T21:15:48+00:00

I have a sharded cluster which has a replica set sharded, my application layer

  • 0

I have a sharded cluster which has a replica set sharded, my application layer is talking to mongos , and now if my primary server goes down, my php application throws an error.
I know this is because I have not enabled setSlaveOkay from the driver by doing something like this:

MongoCursor::$slaveOkay = true;

The problem with this is, where ever I am talking to db I have to add this statement.

Is there a way that I could enable this in the system level?

I tried doing rs.slaveok() in my primary and secondary both but still my application layer is throwing an error .

I also tried db.getMongo().setSlaveOk() in mongos console

The error statement is as follows:

PHP Fatal error:  Uncaught exception 'MongoCursorException' with message 'dbclient error communicating with server: testserver:10001'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:15:50+00:00Added an answer on June 10, 2026 at 9:15 pm

    You can set slaveOK at several levels in PHP: connection, database, collection, or cursor.

    The various details are to be found here:

    http://php.net/manual/en/mongo.queries.php

    You are setting it for each cursor, which is why you are having to call it so often. Instead you can set this at the db or collection level. In terms of what is happening behind the scenes – slaveOK is actually set for each connection – PHP is just managing that for you when you set it for the database, collection, cursor etc.

    Setting it at the mongos or anywhere else in the shell simply sets it for that connection. Once you log out, it is no longer set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application which is set up on IIS7 on Server 2008 R2
I have a 200gb data base on a sharded four node cluster and and
I am using openMPI-1.6 on a cluster, which has 8 nodes and each node
I have a Mongo cluster with 2 shards, RS1 and RS2. RS1 has about
I have a database that is currently sharded. This is the first time that
I have shared object A.so which statically links to libssl.a & another shared object
I have created a multi module maven project. Now I have shared the project
I have a file which compiles without errors or warnings on my macbook pro
I've to move a Windows based multi-threaded application (which uses global variables as well
I'm going through the Sharded Counters example in Java: http://code.google.com/appengine/articles/sharding_counters.html I have a question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.