Pikey has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am running a script that can take up to 70 seconds to complete and chuck out its html. The browser is IE6. Now, sometimes it does what you would expect, and the browser gets the html, other times the browser simply shows "done" in the status bar, with a blank screen. Now, when I track these instances, the browser is showing "done" before the script has completed. I have tried to keep the browser alive by sending chunks of html as it is produced,but no difference. I do not know the content length until the script has completed, so I cannot set the content-length in the header. We are running apache on linux (red-hat), we are NOT using mod_perl.

Replies are listed 'Best First'.
Re: browser timeout?
by dragonchild (Archbishop) on Apr 23, 2004 at 14:36 UTC
    Browser timeout is controlled on the server level. There's a setting in the httpd.conf called, appropriately, TimeOut. It's in seconds. I'll bet if you look at it, you'll see "60". :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Re: browser timeout?
by Plankton (Vicar) on Apr 23, 2004 at 14:40 UTC
    I have a script that even takes longer to run but it sets autoflush ($|=1;) and does prints to keep the browser "interested" so it doesn't timeout. You can take a look at the script here (Jumble solver CGI)

    Plankton: 1% Evil, 99% Hot Gas.
      ok, tried the autoflush, and it looked like it was working, but then,,...it started again, a "done" message in the status bar and blank screen, except for a incrementing "ticker" to indicate progress that was now autoflushing. This time the process lasted 50 seconds. Do you think procmon would kill the process? and if so, shouldnt this return the user some http error such as 500 ? I checked my log the time that the latest failure occured, and the script had just stopped. No die signal was received, it just stopped.
        Are you also writing output periodically? Take a look at the spelled sub in the Jumble solver script. It periodically prints out ".oOo.oOo" string to the browser. Are you doing something like that? If not you'll timeout even though you set autoflush.

        Plankton: 1% Evil, 99% Hot Gas.
Re: browser timeout?
by gjb (Vicar) on Apr 23, 2004 at 14:37 UTC

    You could send an initial HTML page that tells the user that something is happening (this obviously is only sugar) but embed an automatic redirect in the header so that after, say 1.5 minutes another URL is loaded where the script has meanwhile parked the results.

    Hope this helps, -gjb-