Skip to content

Commit b27ee11

Browse files
authored
Merge pull request repejota#80 from dfeyer/task-improve-socket-access
TASK: Improve wait method timeout handling
2 parents 14078bc + 05d8612 commit b27ee11

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
@@ -410,7 +410,8 @@ private function handleMSG($line)
410410
public function wait($quantity = 0)
411411
{
412412
$count = 0;
413-
while (!feof($this->streamSocket)) {
413+
$info = stream_get_meta_data($this->streamSocket);
414+
while (is_resource($this->streamSocket) && !feof($this->streamSocket) && !$info['timed_out']) {
414415
$line = $this->receive();
415416

416417
if ($line === false) {
@@ -428,6 +429,7 @@ public function wait($quantity = 0)
428429
return $this;
429430
}
430431
}
432+
$info = stream_get_meta_data($this->streamSocket);
431433
}
432434
$this->close();
433435

0 commit comments

Comments
 (0)