From 9d24b3314b41eb40f8a33bf7b47d0120e96cca91 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 11 Dec 2021 16:43:07 +0800 Subject: [PATCH] 1 --- src/AsyncClient.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AsyncClient.php b/src/AsyncClient.php index 2b0d52b..2615663 100644 --- a/src/AsyncClient.php +++ b/src/AsyncClient.php @@ -77,13 +77,16 @@ class AsyncClient extends ClientAbstracts * @param $host * @param $isHttps * @param $path + * @throws Exception */ private function generate_client($data, $host, $isHttps, $path): void { + $this->client = new SwowClient(SWOOLE_TCP, TRUE); if ($isHttps || $this->isSSL()) { - $this->client = new SwowClient($host, 443, TRUE); - } else { - $this->client = new SwowClient($host, $this->getPort(), FALSE); + $this->client->enableSSL(); + } + if (!$this->client->connect($host, $this->getPort())) { + throw new Exception('链接失败'); } $this->client->set($this->settings()); if (!empty($this->getAgent())) {