Welcome Guest, Not a member yet? Register   Sign In
Page timeout to blank page with no output...expected?
#1

[eluser]Unknown[/eluser]
Hi,

I have a problem with the page timing out when running a particularly large report, with no error logged.

I can replicate the behaviour with the following code in the controller.

This times out after about 30 seconds in Firefox, and goes to a "Page Cannot be displayed" after 60 in IE:

Code:
for ($i=0;$i<=65;$i++) {
    sleep(1);
}
echo "end";


However, if I echo anything before the slow process, it will run for the expected 65 seconds, before showing "startend" in both:

Code:
echo "start";
for ($i=0;$i<=65;$i++) {
    sleep(1);
}
echo "end";

I have my php time limit set to 120 seconds, php 5, pretty vanilla CodeIgniter install...

Is this something that can be fixed in my configuration, or is it an expected behaviour of the browser with no output?

I suppose I could just echo a space or something first thing on pages that are having problems, but that almost seems like something that should be fixed in CI...

Thanks for any suggestions.
#2

[eluser]Michael Wales[/eluser]
I believe it's a timeout on the browser's behalf.

When you echo out start - the header's are sent immediately prior, then the echo statement, and the browser knows the site is responding.

In your first example, nothing has been echo'ed out, therefore the headers haven't been sent, and the browser doesn't know if the site is responding or not.

You'll prob. have to echo out the space, then run your report - otherwise you battle telling all of your users to manually change their browser's timeout settings.
#3

[eluser]Unknown[/eluser]
Yeah I guess it's more a symptom of using an MVC setup, than a CI problem.

Normally, in the past I would be pounding out table rows to the browser which would keep it alive...

At least it's an easy fix!
#4

[eluser]Michael Wales[/eluser]
Something similar to the following should work in your "pound out rows" concept:

Controller:
Code:
$query = $this->db->get('reports');
  $this->data->reports = $query->result();

View:
Code:
<table>
  foreach ($reports as $report) {
    echo '<tr>
            <td>' . $report->name . </td>
            <td>' . $report->date . </td>
          </tr>';
  }
  </table>




Theme © iAndrew 2016 - Forum software by © MyBB