From 8c2e375a1f1873bec1200d782a7dccdbb971d121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 9 Oct 2020 17:21:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/Socket.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Kafka/Socket.php b/Kafka/Socket.php index 619ffaaa..c1ab358f 100644 --- a/Kafka/Socket.php +++ b/Kafka/Socket.php @@ -248,15 +248,19 @@ class Socket $this->readWatcher = \Amp\onReadable($this->stream, function () { do { - if(!$this->isSocketDead($this->stream)){ - $newData = @fread($this->stream, self::READ_MAX_LEN); - }else{ - $this->reconnect(); - return; - } - if ($newData) { - $this->read($newData); - } + try { + if(!$this->isSocketDead($this->stream)){ + $newData = @fread($this->stream, self::READ_MAX_LEN); + }else{ + $this->reconnect(); + return; + } + if ($newData) { + $this->read($newData); + } + }catch (\Exception $exception){ + var_dump($exception->getMessage()); + } } while ($newData); });