top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Dealing with apache timeout in Perl

+1 vote
606 views

In my web-app there is a HTML screen which provides the facility to select and download documents. If user selects some documents (using checkbox) and submits the form then then all of his selected documents gets downloaded in form of a zip file. What I do is that I take users selected documents and then use Archive::Zip to create Zip file. It works fine.

But if the user had selected a lot of documents then the create_zip subroutine takes a lot of time, and if it takes more than 4 minutes (240 seconds) then apache timeout occurs causing the 503 error, but in the backend the subroutine keeps doing the job, but due to the timeout I cant send the created zip file to users browser.

I am confused how to solve this problem.

posted Sep 4, 2013 by Satish Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

You need to fix this in Apache not in your web-app. The setting is called TimeOut in your httpd.conf - this is the number of seconds Apache will wait before sending a timeout error and ending the request.

answer Sep 4, 2013 by Bob Wise
Sorry I cant do that. Isnt there any other way?
+1 vote

If you don't have control of the web server you're going to have to get creative. Instead of returning the zip file from the page that processes the request, you could:

ok - Fork a process to build the zip and place it in a location specific to the user or their session then return a page with a link to that location and a warning that the link may not work for a few minutes

better - If you're comfortable with javascript (or meta-refresh at a pinch), you could fork the process, then return a page that tells the user that their request is in progress, then periodically refresh the results page until the zip is available.

answer Sep 5, 2013 by Ahmed Patel
Similar Questions
+2 votes

Please tell us about the apache settings so that we can set the Proxytimeout to "each URL"?

example
URL1:
timeout = 60

URL2:
timeout = 300

+2 votes

I recently used the Perl Framework, which is a Perl centric Http test kit. I followed the instructions mentioned in the readme available within the framework which I checked out from the link

http://svn.apache.org/repos/asf/httpd/test/framework/trunk/

The readme states the following steps:
1. You need an installation of Apache. (Either 1.3 or 2.0)
2. Any DSOs you wish to use should be configured in that Apaches
httpd.conf (the test harness will pick this configuration up)
3. Setup:
perl Makefile.PL -apxs /path/to/apache/bin/apxs
4. Run the tests:
t/TEST
5. Evaluate test output.

However, I get an error when I get to the 3rd step saying;

"Cant open perl script "/Perl": No such file or directory"

Hope someone could clarify whats happening here.

+1 vote

There seem to be two modules for it, yet none of them seems to let you do it --- if they do, the documentation doesn't have any example of how to do it.

The alternative seems to be to write MS excel files, and I don't really want to resort to that.

+1 vote

I have a 3rd party perl script:

 head -n 1 /usr/sbin/ftpasswd
#!/usr/bin/perl

I want to write data to stdin and read from stdout:

proc = Popen( ["/usr/bin/perl", "/usr/sbin/ftpasswd" "--hash", "--stdin"], 
stdout=PIPE, stdin=PIPE)

output, input = proc.communicate(pwd)
return output.strip()

Since pwd comes from a non-trusted source I don't want to use shell=True.
The arguments to the perl interpreter do not seem to right:

Can't open perl script "/usr/sbin/ftpasswd--hash": No such file or directory

Adding a leading " " to "--hash" does not help. How can I use that script and achieve something like

# echo "123" | ftpasswd --hash --stdin
ftpasswd: $1$8BuLAqCl$y/URBN/OCSLsKtnu8nFHH0
...