Skip to content

Commit 8b8f82a

Browse files
committed
fixed bug in after connection resolving
1 parent e5a5968 commit 8b8f82a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ public function acquire(
8181
if ($table === null || $table->getTtl() < time()) {
8282
$addresses = $this->resolver->getAddresses($uri->getHost());
8383
$triedAddresses = [];
84+
$canConnect = false;
8485
foreach ($addresses as $address) {
8586
$triedAddresses[] = $address;
8687
if ($this->pool->canConnect($uri->withHost($address), $authenticate)) {
88+
$canConnect = true;
8789
$connection = $this->pool->acquire($uri->withHost($address), $authenticate, $config);
8890
$table = $this->routingTable($connection, $config);
8991
self::$routingCache[$key] = $table;
@@ -92,7 +94,9 @@ public function acquire(
9294
}
9395
}
9496

95-
throw new RuntimeException(sprintf('Cannot connect to host: "%s". Hosts tried: "%s"', $uri->getHost(), implode('", "', $triedAddresses)));
97+
if (!$canConnect) {
98+
throw new RuntimeException(sprintf('Cannot connect to host: "%s". Hosts tried: "%s"', $uri->getHost(), implode('", "', $triedAddresses)));
99+
}
96100
}
97101

98102
$server = $this->getNextServer($table, $config->getAccessMode()) ?? $uri;

0 commit comments

Comments
 (0)