Telling a browser to keep a connection alive
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Jan 3 18:42:35 UTC 2006
On Mon, Jan 02, 2006 at 01:41:59AM -0500, Madison Kelly wrote:
> Does anyone know of a way to tell a web browser to not kill a
> connection (to a cgi script) that takes a certain period of time to respond?
>
> The reason I ask is that my perl program tries to spit out data to
> the browser every 30 seconds during a big job to keep the connection
> alive (I turn off buffering) but sometimes an external program I call
> holds things up for too long and the connection dies anyway.
>
> I know that I can increase the time-out on the webserver but from
> what I can tell the browser generally ends things.
>
> I'm worried that this option won't exist in browsers for valid
> security reasons...
>
> Thanks in advance!
In my experience, as long as there is SOME output in the first 15 to 30
seconds, most browsers will put up with a few minutes of no output.
Of course things like altavista used to do something like this:
Receive request and spin off a background job to work out answer
In the mean time send a page to the user that is set to auto reload in x
seconds to the same page, which each time it is received checks if the
job is done. If it is done, send result, otherwise send the auto
refresh in x seconds page again telling user that the work is still
being done.
Keeps it simple to keep the client happy (since they just refresh), and
lets the work happen undisturbed in the background. Probably much
simpler to program in general than trying to ensure output is generated
frequently. Too easy for the server to be too busy and drop the
connection and then have to do it all over again. Could even add
something that says if the refresh request isn't received within 2x the
expected refresh time, then kill the job because the client is expected
to have quit or closed the page or gone back or something similar. That
part would be harder though since you would need some timeout task
running that each refresh would reset the timeout on.
Len Sorensen
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list