This commit is contained in:
2021-12-11 16:43:07 +08:00
parent 80a2db8974
commit 9d24b3314b
+6 -3
View File
@@ -77,13 +77,16 @@ class AsyncClient extends ClientAbstracts
* @param $host * @param $host
* @param $isHttps * @param $isHttps
* @param $path * @param $path
* @throws Exception
*/ */
private function generate_client($data, $host, $isHttps, $path): void private function generate_client($data, $host, $isHttps, $path): void
{ {
$this->client = new SwowClient(SWOOLE_TCP, TRUE);
if ($isHttps || $this->isSSL()) { if ($isHttps || $this->isSSL()) {
$this->client = new SwowClient($host, 443, TRUE); $this->client->enableSSL();
} else { }
$this->client = new SwowClient($host, $this->getPort(), FALSE); if (!$this->client->connect($host, $this->getPort())) {
throw new Exception('链接失败');
} }
$this->client->set($this->settings()); $this->client->set($this->settings());
if (!empty($this->getAgent())) { if (!empty($this->getAgent())) {