diff --git a/Coroutine/Http.php b/Coroutine/Http.php index 92e4d19..5cecf20 100644 --- a/Coroutine/Http.php +++ b/Coroutine/Http.php @@ -163,14 +163,17 @@ class Http extends Component $open($request); } } - while (($data = $response->recv()) instanceof Frame) { - try { - if ($data->opcode == WEBSOCKET_OPCODE_PING || $data->opcode == WEBSOCKET_OPCODE_PONG) { - continue; + + if ($response->isWritable()) { + while (($data = $response->recv()) instanceof Frame) { + try { + if ($data->opcode == WEBSOCKET_OPCODE_PING || $data->opcode == WEBSOCKET_OPCODE_PONG) { + continue; + } + call_user_func($message, $data); + } catch (\Throwable $throwable) { + $this->logger()->error($throwable->getMessage()); } - call_user_func($message, $data); - } catch (\Throwable $throwable) { - $this->logger()->error($throwable->getMessage()); } } call_user_func($close, $response->fd);