-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to connect to a single member replica set through PHP library #1557
Comments
I just tested one of the example scripts with a single-member replica set and was able to connect to it without an issue. Since you mentioned this is in docker, would you be able to share the setup you were using so we can try to reproduce it? |
Hello @alcaeus, And thank you for taking a look ! Here is the Dockerfile of the built image :
the file initiateReplSet.js contains only one instruction The container is served in a Docker Compose stack, with this service definition :
The connection string configured in my local web app And the ConnectionTimeoutError on read action, through Symfony with Doctrine Mongo ODM : with the head of stack trace
|
I know you mentioned the "rs_dev" is used as the replica set name, but given the behavior you reported I expect the correct name is not actually being passed to the driver. You can also test this locally using SDAM logging and tweaking the connection string. Below are two snippets of running examples/sdam_logger.php on a local single-member replica set (named "rs0") with and without the correct Correct
|
Bug Report
I'm using a single member replica set MongoDB cluster in my development environment (and also in production in some cases), but replica set is well configured. With mongosh, I can connect to the single member by spefying the
replicaSet
URI parameter and it works well.Using PHP driver, if I set a replicaSet option, I get an error
No suitable servers found (
serverSelectionTryOnceset): [connection refused calling hello on '127.0.0.1:27017']. Topology type: ReplicaSetNoPrimary
. But through mongosh, I can check that my single member is obviously seen as PRIMARY :Environment
I'm not using TLS in dev environment, MongoDB is a Docker container (version 7.0) configured with configured
rs_dev
ReplicaSet.Library mongodb/mongodb is 1.19.1
PHP is 8.1
PHP extension is 1.20.1
It seems to be handled the same way by NodeJS driver (same issue described here : https://stackoverflow.com/questions/69531947/replicasetnoprimary-error-although-primary-exists).
Please tell me if this is expected behavior, although mongosh seems OK with single member replica set ?
The text was updated successfully, but these errors were encountered: