Timeout issue in PHPExcel

Topics: User Forum
Oct 6, 2010 at 9:41 PM

I am using PHPExcel to export Excel from MySQL data. It works fine if it can be done within about 30 seconds. But once it is more than 30 seconds, it fails to export. The client web browser always displays a HTTP 500 error.

The Apache server by default is timeout with 300 seconds.

The MySQL interactive_timeout or wait_timeout is 28800 seconds.

The PHP timeout was changed to 120 seconds. In my PHP program, I also use set_time_limit() to add sufficiently longer time.

However, it still doesn't work. The 30 seconds timeout is still there. There is no problem with the data from MySQL.

In fact, the Excel file was partially generated as a .tmp on the server side.

I am running out of ideas what may go wrong. Does PHPExcel has a timeout of 30 seconds also?

Please help me. Thank you,

Coordinator
Oct 6, 2010 at 9:46 PM

PHPExcel doesn't have any timeout limit.... and I'd be cutting my own throat if I implemented one.

Some ISPs do disable changing the timeout limit on their servers.... though trying to doesn't normally throw any exception or error, but simply leaves the timeout value unchanged. It's possible that this is the case.

Oct 7, 2010 at 1:26 AM

Hi Mark,

Actually I own the server. So I have full control over it. For now, I am developing it on a Windows XP machine with a localhost. So I am testing all possible options. But none works. I searched the history of this forum and saw some people has the similar problem. I don't know how they solved the problem.  In fact, the program fails if the output is more than about 5000 rows. The generated temp file for about 5000 rows is only about 1.5MB.

Thank you for the help,

Oct 13, 2010 at 10:53 AM
Edited Oct 13, 2010 at 10:55 AM

i am exporting to excel and it timesout after 1000 lines , the solution can't be changing php settings because that will make the server more vulnerable

i am using a batch method that parition the request to several http requests automatically so that no timeout accurs

on each request i process 500 lines and save them to new worksheet in the excel

the problem on each stage i still have to load/write the whole excel to disk even if i am processing only one sheet with 500 lines

so after creating 5 worksheets the requests timesout

so currently i put a limit on the lines exported to 1000 lines , please provide solution and direction on how to export without line limit

Oct 14, 2010 at 1:15 PM

would it not be possible to make a background job that generates the excel sheet. ie. a script not running through the webserver. Or simply buy a faster server. Another option may be to put the excel generation script in a cgi, and give that specific user more cputime/memory