php超时时间说明【转】

一,http请求超时时间

可能出现的场景:

1,curl进程运行了一个世纪还木结束,curl的时候设置了超时时间 --connect-timeout 1000

2,operation timed out after 1000 milliseconds with 0 bytes received

3,connect() timed out!

wget对超时时间, 是有分阶段的, 比如说请求的超时, 传输的超时,同样HTTP请求有两个超时时间:一个是连接超时时间,另一个是数据传输的最大允许时间,出现问题就要看是哪个超时时间出问题了。

curl命令行

连接超时时间用 --connect-timeout 参数来指定,数据传输的最大允许时间用 -m 参数来指定,时间是毫秒

例如:

curl --connect-timeout 10 -m 20 "http://***"

连接超时的话,出错提示形如:

curl: (28) connect() timed out!

数据传输的最大允许时间超时的话,出错提示形如:

curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

使用PHP的curl_init


当我们执行后,每隔5秒钟,我们会得到一行 Hello World ,如果不按停止按钮,浏览器会不停的一行一行继续加载。

通过这一方法,我们可以完成很多功能,例如机器人爬虫、即时留言板等程序。

如果要停止运行只能重启php-fpm:

查看php-fpm进程数:

ps aux | grep -c php-fpm

查看运行内存

/usr/bin/php  -i|grep mem

重启php-fpm

/etc/init.d/php-fpm restart

原文链接:https://www.cnblogs.com/doseoer/p/6943495.html
原文地址:https://www.cnblogs.com/KillBugMe/p/11805747.html