Skip to content

No suitable servers found: serverSelectionTimeoutMS expired: [socket timeout calling hello on '[myserver]:27017'] #1363

Closed
@Hippolyte-wia

Description

@Hippolyte-wia

Bug Report

I am migrating my mongo databases from my local server to a managed MongoDB on DigitalOcean.
Everything worked fine on my server, but since I migrated all my dbs to the managed mongo server, nothing works anymore.
I always have the same error in my PHP script :

Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found: `serverSelectionTimeoutMS` expired: [socket timeout calling hello on '[myserver]:27017'] in [myserverpath]/finder2.php:41

Stack trace:
#0 [myserverpath]/finder2.php(41): MongoDB\Driver\Manager->executeCommand('db', Object(MongoDB\Driver\Command))
#1 {main} thrown in [myserverpath]/finder2.php on line 41

The only thing I changed is the connection string.
For information, I can connect to the new server with Mongo shell on the same server as the PHP script.

Environment

PHP Version : 7.4.30

Extension informations :
libbson bundled version => 1.20.0
libmongoc bundled version => 1.20.0
libmongoc SSL => enabled
libmongoc SSL library => OpenSSL
libmongoc crypto => enabled
libmongoc crypto library => libcrypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc ICU => enabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled
libmongoc compression zstd => disabled
libmongocrypt bundled version => 1.3.0
libmongocrypt crypto => enabled
libmongocrypt crypto library => libcrypto
mongodb.debug => no value => no value
mongodb.mock_service_id => Off => Off

MongoDB :
Version : MongoDB 5
I don't really know the configuration since it's DigitalOcean who manage everything.
I have the fully managed version with the first configuration and no other options.
The config : 1 GB RAM / 1vCPU / 15 GB Disk / Primary only / AMS3 - MongoDB 5

Test Script

$client = new MongoDB\Driver\Manager(
	'mongodb+srv://[user]:[password]@[doserver]/admin',
	[
		"serverSelectionTryOnce" => false,
		"serverSelectionTimeoutMS" => 5000,
		"tls" => true,
		"ssl" => true,
		"replicaSet" => "db-mongodb-ams3-19362"
	]
);
$command = new MongoDB\Driver\Command(['ping' => 1]);
$client->executeCommand('db', $command);

var_dump($client->getServers());

I tried multiple value for "serverSelectionTimeoutMS" but nothing changes...

Expected and Actual Behavior

Expected Behavior :
The PHP script connects to the DigitalOcean database.

Actual Behavior :
Every time I try to make a request to the new server, it fails with the same error.

Any help on this would be appreciated !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions