Skip to content

Commit 05d8612

Browse files
committed
TASK: Improve wait method timeout handling
Fixes repejota#77
1 parent 883311c commit 05d8612

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Nats/Connection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ private function handleMSG($line)
413413
public function wait($quantity = 0)
414414
{
415415
$count = 0;
416-
while (!feof($this->streamSocket)) {
416+
$info = stream_get_meta_data($this->streamSocket);
417+
while (is_resource($this->streamSocket) && !feof($this->streamSocket) && !$info['timed_out']) {
417418
$line = $this->receive();
418419

419420
if ($line === false) {
@@ -431,6 +432,7 @@ public function wait($quantity = 0)
431432
return $this;
432433
}
433434
}
435+
$info = stream_get_meta_data($this->streamSocket);
434436
}
435437
$this->close();
436438

0 commit comments

Comments
 (0)