Skip to content

Commit

Permalink
feat: Check for 5.2 and 5.1 on generic ConnectException
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Jul 23, 2024
1 parent 6e2b615 commit 7c8b690
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Bolt/ProtocolFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Bolt\Bolt;
use Bolt\connection\IConnection;
use Bolt\error\BoltException;
use Bolt\error\ConnectException;
use Bolt\protocol\V4_4;
use Bolt\protocol\V5;
Expand All @@ -38,11 +37,10 @@ public function createProtocol(IConnection $connection, AuthenticateInterface $a

try {
$protocol = $bolt->build();
} catch (BoltException $e) {
if ($e instanceof ConnectException && $e->getMessage() === 'Wrong version') {
$bolt->setProtocolVersions(5.2, 5.1);
$protocol = $bolt->build();
}
} catch (ConnectException $e) {
// Assume incorrect protocol version
$bolt->setProtocolVersions(5.2, 5.1);
$protocol = $bolt->build();
}

if (!($protocol instanceof V4_4 || $protocol instanceof V5 || $protocol instanceof V5_1 || $protocol instanceof V5_2 || $protocol instanceof V5_3 || $protocol instanceof V5_4)) {
Expand Down

0 comments on commit 7c8b690

Please sign in to comment.