http-client swoole协程 使用代理高并发出现报错

筱洛洛

问题描述

webman使用swoole协程,开启1进程,在使用错误的代理的情况下,50并发有大几率触发报错【ErrorException: Swoole\Coroutine::resume(): can not resume the coroutine which is in IO operation or non-existent in /var/www/vendor/workerman/coroutine/src/Coroutine/Swoole.php:88】
错误的代理=不可用的代理

截图

程序代码或配置

public function index()
    {
        $http = new \Workerman\Http\Client(['connect_timeout' => 3, 'timeout' => 3,]);
        $ip="10.0.1.2:8080";
        try {
            $response = $http->request('https://r.inews.qq.com/api/ip2city',['method' => 'GET','proxy' => "http://".$ip,])->getBody()->getContents();
        }catch (\Exception $e){
            $response = $e->getMessage();
        }
        var_dump($ip."  ".$response);
        return $ip."  ".$response;
    }

重现问题的步骤

使用以上代码,直接压测即可
截图

操作系统环境及workerman/webman等具体版本

Workerman/5.1.3
PHP/8.1.31 (JIT off)
Linux/6.6.87.2-microsoft-standard-WSL2
workerman/http-client 3.0.4
workerman/webman-framework 2.1.2
swoole 5.1.7

32 0 0
0个回答

🔝