@@ -3,31 +3,31 @@ ConnectionTimeoutException: exceeding sockettimeoutms
3
3
--SKIPIF--
4
4
<?php require __DIR__ . "/../utils/basic-skipif.inc " ; ?>
5
5
<?php skip_if_not_live (); ?>
6
- <?php skip_if_not_clean (); ?>
7
6
<?php skip_if_test_commands_disabled (); ?>
8
7
<?php skip_if_sleep_command_unavailable (); ?>
9
8
--FILE--
10
9
<?php
11
10
require_once __DIR__ . "/ " . "../utils/basic.inc " ;
12
11
13
- $ uri = append_uri_option (URI , 'sockettimeoutms=9 ' );
12
+ /* A 500ms socket timeout will ensure that SDAM and any authentication can
13
+ * complete before executing a sleep command to trigger a network error. */
14
+ $ uri = append_uri_option (URI , 'sockettimeoutms=500 ' );
14
15
$ manager = new MongoDB \Driver \Manager ($ uri );
15
16
16
- $ cmd = array (
17
- "sleep " => 1 ,
18
- "w " => false ,
19
- "secs " => 2 ,
20
- );
21
- $ command = new MongoDB \Driver \Command ($ cmd );
17
+ $ command = new MongoDB \Driver \Command ([
18
+ 'sleep ' => 1 ,
19
+ 'secs ' => 1 ,
20
+ 'w ' => false ,
21
+ ]);
22
22
23
- throws (function () use ($ manager , $ command ) {
24
- $ result = $ manager ->executeCommand ("admin " , $ command );
25
- var_dump ($ result ->toArray ());
26
- }, "MongoDB\Driver\Exception \\ConnectionTimeoutException " );
23
+ echo throws (function () use ($ manager , $ command ) {
24
+ $ manager ->executeCommand ('admin ' , $ command );
25
+ }, 'MongoDB\Driver\Exception \\ConnectionTimeoutException ' ), "\n" ;
27
26
28
27
?>
29
28
===DONE===
30
29
<?php exit (0 ); ?>
31
30
--EXPECT--
32
31
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
32
+ Failed to send "sleep" command with database "admin": Failed to read 4 bytes: socket error or timeout
33
33
===DONE===
0 commit comments