I am trying to connect to a mongo replica set using PHP,
my code looks like this:
$options = array(
'replicaSet' => 'Repset',
'readPreference' => 'primaryPreferred',
);
$connection = new MongoClient("mongodb://ip-10-1-2-3.ec2.internal:27017,ip-10-1-2-4.ec2.internal:27017/", $options);
When I do this I get an error back:
No candidate servers found
if I simplify the connect string to :
$connection = new MongoClient("mongodb://ip-10-1-2-4.ec2.internal:27017/");
Then it connects to the server, but this is not the right way, given I am using replica Sets
What am I doing wrong, the connect script seems right but obviously isn't.
Would appreciate any help.
您是否尝试过删除$ options之前的空格?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.