diff --git a/src/channel/PhutilSocketChannel.php b/src/channel/PhutilSocketChannel.php --- a/src/channel/PhutilSocketChannel.php +++ b/src/channel/PhutilSocketChannel.php @@ -117,7 +117,8 @@ // NOTE: fread() continues returning empty string after the socket is // closed, we need to check for EOF explicitly. if ($data === '') { - if (feof($socket)) { + $stream_meta_data = stream_get_meta_data($socket); + if (feof($socket) || $stream_meta_data['unread_bytes'] <= 0) { $this->closeReadSocket(); } }