webman使用swoole協(xié)程,開啟1進(jìn)程,在使用錯誤的代理的情況下,50并發(fā)有大幾率觸發(fā)報(bào)錯【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