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

Dear Monks,
I have a problem somewhere in my system that I can not figure out and am here to seek your help. I am running my perl script on an Apache server. The perl script invokes an external program and every second gets a response back from this external program telling it how many percent of the job has been completed among other statistical data. The script then pushes these data to the client machine running Firefox. It usually runs to completion most of the times but once in awhile, especially on a long running job, it just died in the middle of the runs but no error message is displayed on the client machine's window. The external program no longer existed when I type in ps -aux. I looked thru the Apache error_log in /etc/httpd/logs but found nothing in there. If I run the external program manually, everything is fine so the problem is not with the external program. Any help would be appreciated.
Attached is part of my code but the problem might not be with the code though.
Thanks in advance for your help.
print "Content-type: multipart/x-mixed-replace;"; print "boundary=magicalboundarystring\n\n"; print "--magicalboundarystring\n"; $com = "./myapp 5000"; open PIPE, "$com |"; while ($data = <PIPE>) { my ($read, $write, $update, $complete) = split(/::/, $data); print "Content-type: text/html\n\n"; print "Percent completed: $complete\n"; print "Write Time: $write\n"; print "Read Time: $read\n"; print '</body>'; print '</html>'; print "\n--magicalboundarystring\n"; } close(PIPE);

20070822 Janitored by Corion: Put code into code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Perl Script Server Push Died while running
by clinton (Priest) on Aug 21, 2007 at 15:38 UTC
    How long is your process taking? Could it be longer than the Timeout value that you have set in your Apache config? (see Timeout directive in Apache's docs).

    Clint

      With server push, it should get around the timeout issue that is set in the Apache config since the connection is always opened to the client, but I don't think this is the problem since it sometimes died within 10 seconds of the test that was supposed to be 5000 seconds. I suspected that the c program is sending request packages to the database application on another machine (there are only three machines right now within a network hub, one running the database application, the second running the Apache web server, and the third running the browser) and every second returned statistic data to the perl script. When the perl script pushed the data to the web client, the package got collided with the database requests from the C program to the database application and caused the connection between the perl script and Firefox to die. I am not sure how to verify this is to be the case. I did notice that when I set the data to be returned from the C program to every 20 seconds, the problem is less likely to occur. Any help?