5 分钟后 php readfile_chunked 失败

发布于 2024-12-15 17:40:17 字数 415 浏览 1 评论 0原文

这就是我现在所得到的:

$chunksize = 1024*4;
$h = fopen($file, 'rb');
set_time_limit(600);
while(!feof($h)){
    echo fread($h, $chunksize);
    flush();
}
fclose($h);

我尝试过增加块大小,我尝试过每次迭代重置超时,我尝试过将超时设置为零(最初是 5 分钟),我什至尝试过将flush()放在循环之外,让其自己的缓冲区处理它,每次下载都会在5分钟内终止。有时它是50.2MB,有时它是54.8或介于两者之间的任何东西,所以我知道这不是文件大小。 php_info() 说最大时间是 30 秒,所以我可以将其增加到 300,但仅此而已。

IIS(服务器2003)中是否有某些东西可以覆盖它?

This is what I've got at the moment:

$chunksize = 1024*4;
$h = fopen($file, 'rb');
set_time_limit(600);
while(!feof($h)){
    echo fread($h, $chunksize);
    flush();
}
fclose($h);

I've tried increasing the chunk size, I've tried resetting the timeout with every iteration, I've tried setting the timeout to zero (it was originally 5min), I even tried putting the flush() outside the loop to let its own buffer take care of it, and every single time the download dies at exactly 5 minutes in. Sometimes it's 50.2MB, sometimes it's 54.8 or anything in between, so I know it's not the file size. php_info() says the maximum time is 30seconds, so somehow I am able to increase it to 300 but that's it.

Is there something in IIS (server 2003) that could be overriding it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无名指的心愿 2024-12-22 17:40:17

啊,微软 MVP。每当他们说某件事是不可能的时,你就知道这只是挖掘的问题。

http://www.murraymoffatt.com/software-problem-0002.html

我能够为这个特定文件提供无限的运行时间,而不会影响网站的其余部分。

编辑:
看来这些文章开始消失了。

在 IIS 5.0 (Win2K) 中重置 FastCGI 超时:

  • 启动 IIS 管理控制台(开始 => 设置 => 控制面板 =>
    管理工具 =>互联网服务经理)。
  • 在控制台左侧的树中,您应该看到“Internet
    信息服务”位于最顶部,下面是名称
    你的电脑。右键单击您的计算机名称并选择“属性”。
  • 在“主属性”下是一个列表框;确保
    显示“WWW 服务”,然后单击“编辑”按钮。
  • 单击“主目录”选项卡。
  • 单击应用程序设置区域中的“配置”按钮。
  • 单击“处理选项”选项卡。
  • 在 CGI 配置区域中有一个“CGI 脚本超时”值
    以秒为单位指定。默认值为 300 秒(5 分钟)。
  • 将此值更改为您希望的超时值。
  • 单击每个窗口上的“确定”按钮,直到出现
    直接回到IIS管理控制台。关闭管理
    安慰。
  • 通过打开命令提示符重新启动 IIS(开始 => 程序
    =>配件=>命令提示符)并键入命令:iisreset

IIS 5.1 (WinXP):

  • 打开 IIS。
  • 展开计算机名称。
  • 右键单击“网站”并选择“属性”。
  • 转到“主目录”选项卡。
  • 单击“配置”按钮,弹出另一个窗口。
  • 转到“进程选项”选项卡。
  • 按照您的意愿设置。
  • 好的,出去。

以下是 IIS 6.0 的说明: http://www.iisadmin.co.uk/?p= 7
但 MetaEdit 的下载链接已损坏,因此请在此处尝试:http://support.microsoft.com/kb/ 301386

Ah, Microsoft MVPs. Whenever they say something's impossible, you know it's just a matter of digging.

http://www.murraymoffatt.com/software-problem-0002.html

I was able to give this one specific file an unlimited run time without affecting the rest of the site.

EDIT:
Looks like those articles are starting to disappear.

Resetting FastCGI Timeout in IIS 5.0 (Win2K):

  • Start the IIS management console (Start => Settings => Control Panel =>
    Administrative Tools => Internet Services Manager).
  • In the tree on the left-hand side of the console you should see "Internet
    Information Services" at the very top, then below this the name of
    your computer. Right-click your computer name and select "Properties".
  • Under "Master Properties" is a listbox; ensure that
    "WWW Service" is showing, then click the "Edit" button.
  • Click on the "Home Directory" tab.
  • Click on the "Configuration" button in the Application Settings area.
  • Click on the "Process Options" tab.
  • In the CGI Configurations area there is a "CGI script timeout" value
    specified in seconds. The default value is 300 seconds (5 minutes).
  • Change this value to whatever you would like your timeout to be.
  • Work your way out by clicking the "Ok" button on each window until you get
    right back to the IIS management console. Close the management
    console.
  • Restart IIS by opening a command prompt (Start => Programs
    => Accessories => Command Prompt) and type the command: iisreset

IIS 5.1 (WinXP):

  • Open IIS.
  • Expand computer name.
  • Right-click on "Web Sites" and choose Properties.
  • Go to "Home Directory" tab.
  • Click the "Configuration" button, brings up another window.
  • Go to the "Process Options" tab.
  • Set as your heart desires.
  • Ok out.

Here's the instructions for IIS 6.0: http://www.iisadmin.co.uk/?p=7
but the download link for MetaEdit is broken, so try here: http://support.microsoft.com/kb/301386

尸血腥色 2024-12-22 17:40:17

我遇到了完全相同的问题..

对于任何人来说,这些解决方案是特定于 Windows IIS 的。

我刚刚花了 2 天尝试了每一种可能的配置,设置了 300 秒来尝试解决问题。

我更改了配置数据库中的 CGITimeout 值,但就我而言,罪魁祸首是 FastCGI ini 文件(位于 c:\windows\system32\inetsrv\fcgiext.ini 中)

有一个设置 (以秒为单位):

ActivityTimeout=300

更改此值并重新启动 IIS。

I was experiencing the EXACT same problem ..

For anyone looking, these solutions are specific to Windows IIS

I just went through 2 days of trying every possible config that had a setting of 300 seconds to try to fix the issue.

I changed the CGITimeout value in the metabase, but in my case the culprit turned out to be the FastCGI ini file (located in c:\windows\system32\inetsrv\fcgiext.ini)

There's a setting (in seconds):

ActivityTimeout=300

Change this value and restart IIS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文