duanchi6397 2010-05-22 12:45
浏览 107
已采纳

PHP connection_aborted不能与nginx一起使用?

I can't seem to get the function connection_aborted to work with nginx. The code I used to test is as follow:

<?php
ignore_user_abort(true);
ob_implicit_flush();
$i = 0;
while (!connection_aborted()) {
    echo $i;
    $i++;
    sleep(1);
}
file_put_contents('test',$i);

In Apache, it works correctly, although it delays a little. i.e. When I press stop button on browser when "3", the 'test' file shows "8". That is an acceptable margin, but on nginx, it doesn't seem to output anything to the 'test' file.

  • 写回答

2条回答 默认 最新

  • dongpai1942 2010-05-23 16:11
    关注

    Check your Nginx configuration, it should have

    fastcgi_ignore_client_abort off;
    

    This configuration key has off as the default, so even if you have no fastcgi_ignore_client_abort at all, your script should work as expected.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!