国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

http-client提示【域名】has been closed

dgkerry

問題描述

我使用Workerman\Http\Client來(lái)對(duì)外請(qǐng)求(并開啟了協(xié)程),我發(fā)現(xiàn)在請(qǐng)求個(gè)別網(wǎng)站時(shí)會(huì)提示has been closed,我在本站和google上搜索與此有關(guān)的問題,有些人說(shuō)ssl問題,于是我Workerman\Http\ConnectionPool的create中記錄是否關(guān)閉ssl,事實(shí)上已關(guān)閉,我嘗試寫一個(gè)普通的curl來(lái)請(qǐng)求,卻可以拿到數(shù)據(jù),請(qǐng)問是什么回事呢

程序代碼

$http = new Client();
$option=[
   'method' => 'get',
   'version' => '1.1',
];
$testnet=$http->request('【域名】',$option);

ssl關(guān)閉

#ConnectionPool 的create
protected function create($address, bool $ssl = false, string $proxy = ''): AsyncTcpConnection
    {
        $log = Log::channel('log2');//<----
        $context = [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name'  => false,
                'allow_self_signed' => true
            ],
            'http' => [
                'proxy' => $proxy,
            ]
        ];
        if (!empty( $this->options['context'])) {
            $context = array_merge($context, $this->options['context']);
        }
        if (!$ssl) {
            unset($context['ssl']);
        }
        if (empty($proxy)) {
            unset($context['http']['proxy']);
        }
        if (!class_exists(Worker::class) || is_null(Worker::$globalEvent)) {
            throw new Exception('Only the workerman environment is supported.');
        }
        $log->info('create:'.json_encode($context));
        $connection = new AsyncTcpConnection($address, $context);
        if ($ssl) {
            $connection->transport = 'ssl';//<----
        }
        ProxyHelper::setConnectionProxy($connection, $context);
        $connection->address = ProxyHelper::addressKey($address, $proxy);
        $connection->connect();
        $connection->pool = ['connect_time' => time()];
        return $connection;
    }

    ##日志結(jié)果:[2025-04-07 18:58:59] log2.INFO: create:{"ssl":{"verify_peer":false,"verify_peer_name":false,"allow_self_signed":true},"http":[]}

報(bào)錯(cuò)信息

RuntimeException: The connection to 【域名】 has been closed. in /www/wwwroot/【項(xiàng)目】/vendor/workerman/http-client/src/Request.php:551
Stack trace:
#0 /www/wwwroot/【項(xiàng)目】/vendor/workerman/workerman/src/Connection/TcpConnection.php(1062): Workerman\Http\Request->onUnexpectClose()
#1 /www/wwwroot/【項(xiàng)目】/vendor/workerman/workerman/src/Connection/TcpConnection.php(874): Workerman\Connection\TcpConnection->destroy()
#2 /www/wwwroot/【項(xiàng)目】/vendor/workerman/workerman/src/Connection/AsyncTcpConnection.php(398): Workerman\Connection\TcpConnection->doSslHandshake()
#3 /www/wwwroot/【項(xiàng)目】/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\AsyncTcpConnection->checkConnection()
#4 [internal function]: Workerman\Events\Swoole->Workerman\Events\{closure}()
#5 {main}

操作系統(tǒng)及workerman/webman等框架組件具體版本

linux
-------composer.json--------
workerman/http-client ^3.0
workerman/webman-framework ^2.1

200 1 1
1個(gè)回答

walkor 打賞

使用swoole訪問https地址需要swoole開啟openssl。
另外,如果使用了swoole,就沒必要使用http-client了,curl就可以了

  • 暫無(wú)評(píng)論
??