File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -449,7 +449,7 @@ public function setStreamTimeout($seconds)
449
449
if ($ this ->isConnected ()) {
450
450
if (is_int ($ seconds )) {
451
451
try {
452
- return $ this -> streamWrapper -> setStreamTimeout ($ this ->streamSocket , $ seconds );
452
+ return stream_set_timeout ($ this ->streamSocket , $ seconds );
453
453
} catch (\Exception $ e ) {
454
454
return false ;
455
455
}
@@ -489,4 +489,13 @@ public function close()
489
489
fclose ($ this ->streamSocket );
490
490
$ this ->streamSocket = null ;
491
491
}
492
+
493
+
494
+ /**
495
+ * @return resource
496
+ */
497
+ public function streamSocket ()
498
+ {
499
+ return $ this ->streamSocket ;
500
+ }
492
501
}
Original file line number Diff line number Diff line change @@ -161,6 +161,32 @@ function ($message) use ($contentLen) {
161
161
162
162
}
163
163
164
+ /**
165
+ * Test setting a timeout on the stream
166
+ *
167
+ * @return void
168
+ */
169
+ public function testSetStreamTimeout ()
170
+ {
171
+ $ this ->c ->setStreamTimeout (1 );
172
+ $ before = time ();
173
+ $ this ->c ->request (
174
+ "nonexistantsubject " ,
175
+ "test " ,
176
+ function ($ message ) {
177
+ $ this ->fail ("should never have gotten here " );
178
+ }
179
+ );
180
+ $ timeTaken = time () - $ before ;
181
+
182
+ $ this ->assertGreaterThan (0 , $ timeTaken );
183
+ $ this ->assertLessThan (3 , $ timeTaken );
184
+
185
+ $ meta = stream_get_meta_data ($ this ->c ->streamSocket ());
186
+
187
+ $ this ->assertTrue ($ meta ["timed_out " ]);
188
+ }
189
+
164
190
/**
165
191
* Test Unsubscribe command.
166
192
*
You can’t perform that action at this time.
0 commit comments