workerman执行busy,http请求不返回导致阻塞

  • 问题:在workerman系统执行一段时间会出现进程busy情况
    在这里插入图片描述
  • 查找原因,可以看到一个fd出现异常

strace -ttp 25308

lsof -nPp 25308

查看进程执行的描述,发现是执行了一个http请求,是一个请求长时间不返回导致的阻塞,这里需要对请求进行超时时间的设置

这里使用了GuzzleHttp拓展包,设置方式

  • 方式一
$client = new Client([
    'timeout'  => 2.0,
]);
  • 方式二
$client = new Client();
 $res = $client->request('GET', $url, ['timeout' =>2.0]);

Supongo que te gusta

Origin blog.csdn.net/weixin_43674113/article/details/119866140
Recomendado
Clasificación