Skip to content

Commit 6d9238d

Browse files
Update ProtocolFactory.php (#250)
* Update ProtocolFactory to have more flexible version negotiation --------- Co-authored-by: Ghlen Nagels <[email protected]>
1 parent 144df14 commit 6d9238d

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/Bolt/ProtocolFactory.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use Bolt\Bolt;
1717
use Bolt\connection\IConnection;
18-
use Bolt\error\ConnectException;
1918
use Bolt\protocol\V4_4;
2019
use Bolt\protocol\V5;
2120
use Bolt\protocol\V5_1;
@@ -33,18 +32,11 @@ class ProtocolFactory
3332
public function createProtocol(IConnection $connection, AuthenticateInterface $auth, string $userAgent): array
3433
{
3534
$bolt = new Bolt($connection);
36-
$bolt->setProtocolVersions(5.4, 5.3, 5, 4.4);
37-
38-
try {
39-
$protocol = $bolt->build();
40-
} catch (ConnectException $e) {
41-
// Assume incorrect protocol version
42-
$bolt->setProtocolVersions(5.2, 5.1);
43-
$protocol = $bolt->build();
44-
}
35+
$bolt->setProtocolVersions('5.4.4', 4.4);
36+
$protocol = $bolt->build();
4537

4638
if (!($protocol instanceof V4_4 || $protocol instanceof V5 || $protocol instanceof V5_1 || $protocol instanceof V5_2 || $protocol instanceof V5_3 || $protocol instanceof V5_4)) {
47-
throw new RuntimeException('Client only supports bolt version 4.4 and ^5.0');
39+
throw new RuntimeException('Client only supports bolt version 4.4 to 5.4');
4840
}
4941

5042
$response = $auth->authenticateBolt($protocol, $userAgent);

0 commit comments

Comments
 (0)