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/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