This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -449,7 +449,7 @@ public function setStreamTimeout($seconds)
449449 if ($ this ->isConnected ()) {
450450 if (is_int ($ seconds )) {
451451 try {
452- return $ this -> streamWrapper -> setStreamTimeout ($ this ->streamSocket , $ seconds );
452+ return stream_set_timeout ($ this ->streamSocket , $ seconds );
453453 } catch (\Exception $ e ) {
454454 return false ;
455455 }
@@ -489,4 +489,13 @@ public function close()
489489 fclose ($ this ->streamSocket );
490490 $ this ->streamSocket = null ;
491491 }
492+
493+
494+ /**
495+ * @return resource
496+ */
497+ public function streamSocket ()
498+ {
499+ return $ this ->streamSocket ;
500+ }
492501}
Original file line number Diff line number Diff line change @@ -161,6 +161,32 @@ function ($message) use ($contentLen) {
161161
162162 }
163163
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+
164190 /**
165191 * Test Unsubscribe command.
166192 *
You can’t perform that action at this time.
0 commit comments