PHP closes the connection after 10 seconds without reflecting data

I have a PHP webpage that generates statistics and takes about 15 seconds to create them before sending them to the browser.

The problem is that the browser finishes loading with a blank page. Unfortunately, I do not have access to the error_log file.

But I thought that if I start sending data in a foreach-loop, which consumes most of the generation time, for example,

echo ' ';

the connection does not end and the page loads.

At first I thought it could be a memory_limit or max_execution_time problem, so I increased both without luck. But that would also be strange for me, since hitting max_execution_time will result in a blank page, regardless of whether I submit echo ' 'or not.

Is there another PHP parameter that I don’t know that will lead to disconnection after 10 seconds without sending data?

Edit

The page is not full. Here are the data sent:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta name="author" content="Gerd Grützmacher">
  <meta name="robots" content="index,follow">
  <meta http-equiv="Language" content="de">  
  <link rel="icon" href="/favicon.png" type="image/png">

  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

  <!--[if (gte IE 5.9)]><!-->
  <link rel="stylesheet" type="text/css" href="css/gruppenunterkuenfte-min.css" />
  <!--<![endif]-->

  <!--[if IE 6]>
  <style type="text/css" media="screen, projection">
       @import url(css/ie6.css);
  </style>
  <![endif]-->

  <!--[if gte IE 5.9]><!-->
    <script type="text/javascript" src="scripts.js"></script>
  <!--<![endif]-->

After this point, statistics are generated, so I see only a blank page.

Here is the HTTP header:

quest URL:http://gruppenunterkuenfte.de/index.php?mod=home&action=stats_belegungsanfrage2
Request Method:GET
Status Code:200 OK
Request Headers
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Cache-Control:max-age=0
Referer:http://gruppenunterkuenfte.de/index.php?mod=home&action=stats_belegungsanfrage2
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3
Query String Parameters
mod:home
action:stats_belegungsanfrage2
Response Headers
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Type:text/html; charset=utf-8
Date:Sat, 25 Sep 2010 15:07:11 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache
Server:Apache/2.2.16
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.11
+3
source share
10 answers

Here are my 2 cents:

First of all, I would make sure that all types of buffering are disabled. The gentleman was kind enough to provide this code once:

@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);

echo ' '; . , , , - , , . , , , .

0

, , - .

char (' ' ), flush() , , , . , ; , .

+1

, , - , - .

, .

0

, , - :

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
0

, error_log.

Errr... error_log /, ? script ini_set, ..

ini_set('log_errors', 1);
ini_set('error_log', '/path/to/yourlog.log');

error_reporting .

0

? . , , (, php ).

  • , localhost
  • - - ( , firefox ), - .

- , JS . script ?

0

, . HTML. :

echo preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/','',$output);

, (, , ).

0

script (Content-Type - )?

0

, ajax iframe - iframe. iframe meta-refresh, - ajax php-.

0

, Apache, , , PHP. . Apache PHP ? ?

'' , sleep (10). , , 10 .

See what you do inside the foreach loop. There are hundreds of things that could crash Apache, PHP, or both. Especially in scenarios where you crunch heavy data.

0
source

Source: https://habr.com/ru/post/1766546/


All Articles