Close connection on error while read or write
This commit is contained in:
@@ -205,24 +205,32 @@ abstract class Connection
|
|||||||
|
|
||||||
protected function read(): Promise
|
protected function read(): Promise
|
||||||
{
|
{
|
||||||
try {
|
return call(function () {
|
||||||
return $this->stream->read();
|
try {
|
||||||
} catch (\Throwable $e) {
|
return $this->stream->read();
|
||||||
$this->close(false);
|
} catch (\Throwable $e) {
|
||||||
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
|
|
||||||
return new Failure($e);
|
$this->close(false);
|
||||||
}
|
|
||||||
|
return new Failure($e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function write(string $data): Promise
|
protected function write(string $data): Promise
|
||||||
{
|
{
|
||||||
try {
|
return call(function () use ($data) {
|
||||||
return $this->stream->write($data);
|
try {
|
||||||
} catch (\Throwable $e) {
|
return yield $this->stream->write($data);
|
||||||
$this->close(false);
|
} catch (\Throwable $e) {
|
||||||
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
|
|
||||||
return new Failure($e);
|
$this->close(false);
|
||||||
}
|
|
||||||
|
return new Failure($e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleError(Frame\Error $error): void
|
protected function handleError(Frame\Error $error): void
|
||||||
|
Reference in New Issue
Block a user