-
-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
I encountered hanging feof
resulting in StreamException("The stream was closed by the peer")
.
This happens when doing requests in Kubernetes to Facebook.
Omitting the feof check "fixes" it.
A workaround (and better code) would be to not check on @feof
before the write but setting an error handler for the fwrite
and cathing warnings and converting them to stream exceptions.
Example:
$eh = set_error_handler([$this, 'onSocketWriteError']);
if ($chunkSize) {
$written = \fwrite($stream, $data, $chunkSize);
} else {
$written = \fwrite($stream, $data);
}
set_error_handler($eh);