diff --git a/src/Client.php b/src/Client.php index 9f7ef2ee2d..9299cbddcd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -118,8 +118,11 @@ class Client if ($this->client->isConnected()) { return $this; } + + if(!$this->client->connect($this->host, $this->port)){ + throw new \Exception("Failed to connect to MongoDB"); + } - $this->client->connect($this->host, $this->port); [$payload, $db] = $this->auth->start(); $res = $this->query($payload, $db); @@ -934,4 +937,4 @@ class Client $this->replicaSet = property_exists($result, 'setName'); return $this->replicaSet; } -} +} \ No newline at end of file