密集的PHP脚本失败w /"指定的超时已过期"错误/ ap_content_length_filter

sbu*_*uck 9 php

运行失败的MySQL密集型PHP脚本.Apache日志报告此:

[Wed Jan 13 00:20:10 2010] [error] [client xxx.xx.xxx.xxxx] (70007)
The timeout specified has expired:
ap_content_length_filter: apr_bucket_read() failed,
referer: http://domain.com/script.php
Run Code Online (Sandbox Code Playgroud)

试过把它放在set_time_limit(0)顶部.

也试过了 set_time_limit(0)

既没有修复超时.

我可以在http.conf(或其他地方)设置一些特定的超时限制来防止这种情况吗?

小智 7

我使用Apache 2.4.6PHP 5.4.23 FPM/FastCGI打了一个非常相似的墙.

症状:

无论我在PHP或Apache中设置什么,我的脚本都会在30秒内超时,我会在Apache错误日志中看到以下内容:

[timestamp] [proxy_fcgi:error] [pid...] (70007)The timeout specified has expired: [client ...] AH01075: Error dispatching request to :

我的VirtualHost:

TimeOut  300
KeepAliveTimeout 300

<IfModule reqtimeout_module>
  RequestReadTimeout header=120-240,minrate=500
  RequestReadTimeout body=120,minrate=500
</IfModule>

<IfModule mod_proxy.c>
  ProxyTimeout 300
</IfModule>

<IfModule mod_fcgid.c>
  FcgidConnectTimeout 300
</IfModule>
Run Code Online (Sandbox Code Playgroud)

讨厌的PHP脚本:

ini_set( 'max_execution_time', '120' );
...
ini_restore( 'max_execution_time' );
Run Code Online (Sandbox Code Playgroud)

修复:它是Apache中的硬编码值mod_proxy_fcgi

看看这里的错误报告

  • 补丁(上面的链接)
  • 该修复程序似乎尚未定为一般版本(2014年3月)


nem*_*ixx 5

首先,我的解决方案仅适用于Apache Web Server.

我正在编写一个脚本,用作针对非常大的数据库的报告的csv下载脚本,我也遇到了这个问题.不是使用PHP,而是我的脚本是用一些名不见经传的语言写成的heitml ;-)

请求超时问题确实发生在我的方案中,如下所示:

[Wed Sep 19 20:29:01 2012] [warn] [client ::1] Timeout waiting for output from CGI script /var/www/cgi-bin/heitml
[Wed Sep 19 20:29:01 2012] [error] [client ::1] (70007)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed
Run Code Online (Sandbox Code Playgroud)

我目前可以适应的唯一严肃的解决方案是在这里使用这个官方超时配置扩展:mod_reqtimeout.它允许调整超时参数,例如:

允许10秒钟接收包括标题的请求,以及30秒接收请求正文:

RequestReadTimeout header=10 body=30
Run Code Online (Sandbox Code Playgroud)

至少需要10秒钟才能收到请求正文.如果客户端发送数据,则每收到1000个字节,将超时时间增加1秒,超时没有上限(由LimitRequestBody间接给出的限制):

RequestReadTimeout body=10,MinRate=1000
Run Code Online (Sandbox Code Playgroud)

至少需要10秒钟才能收到包含标题的请求.如果客户端发送数据,则每收到500字节将超时时间增加1秒.但请求包括标头的时间不要超过30秒:

RequestReadTimeout header=10-30,MinRate=500
Run Code Online (Sandbox Code Playgroud)

通常,服务器应配置标头和正文超时.如果http和https虚拟主机使用通用配置,则超时不应设置得太低:

RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
Run Code Online (Sandbox Code Playgroud)

还没有找出Apache提供的更好的解决方案是否需要我使用这个模块(假设它没有默认安装 - 尽管它包含在所有版本2.2.15及更高版本中).


Jef*_*eck 0

php.ini也有一个超时。