[cgiapp] Keep connection alive for request that takes long time to run

Mark Stosberg mark at summersault.com
Fri Feb 12 10:58:37 EST 2010


On Wed, 10 Feb 2010 10:38:00 -0500
"Shao, David (NIH/NLM/NCBI) [C]" <shaod at ncbi.nlm.nih.gov> wrote:

> Hi,
> 
> I use CGI::Application for my web app. The app sometimes takes longer
> to run than the timeout limit set by the apache server, which results
> in a 'Bad Gateway' page at user side. My web admin suggested I need to
> implement something similar to 'heartbeat' to keep the connection
> alive. My interpretation to this is, while my app is running, it needs
> to send a 'keepalive' packet to the client in short intervals (i.e.
> shorter than the timeout limit), to prevent the server from dropping
> the connection. I am fairly new to CGI::Application, and my questions
> are if this feature already exists (but I can't find it in
> documentation), or if it is not, is it possible to implement using
> CGI::Application?

Michael Peters is right that the ::Stream plugin concepts may be helpful
here.

I will offer an additional perspective which might be helpful. I had a
long running report which was timing out. Because we knew the report
took a long time, it was already designed to e-mail the report when it
was done, rather than providing a synchronous response.

This turned out to a great use for AJAX. We used AJAX to start
the long-running report, and then immediately returned a result back
to the screen indicating that the report would eventually arrive by
e-mail.

    Mark




More information about the cgiapp mailing list