LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP script timeout (https://www.linuxquestions.org/questions/linux-software-2/php-script-timeout-136936/)

J_Szucs 01-20-2004 09:46 PM

PHP script timeout
 
I always get a 30s script timeout when I do a long database search (>30s) via a https connection from a remote place to an apache+PHP+PostgreSQL server.

Most strange is that my php.ini contains much longer script timeout value, and in fact I do not have the timeout when I do the same database search from within the LAN where the server resides.
I do not have the timeout when I access a static page or download a large file from the same server from the outside, either.

So it seems as if the timeout would only concern dynamic PHP pages and only if they are accessed from outside of the LAN.

Have you ever experienced such PHP behaviour? Is there a workaround?

Pcghost 01-21-2004 03:17 PM

Try adding this to your php script immediatly before you begin the query

set_time_limit(20*60);

That allows for 20 minutes and solved a similar problem I had recently.

J_Szucs 01-21-2004 10:16 PM

The set_time_limit(360) command has been there for a long time, yet I had the 30s timeout...

Presently I cannot easily reproduce the timeout as I do a database maintenance very often and the queries run quicker.

Yet, I am pretty sure the 30s timeout is there as always.

looseCannon 01-22-2004 11:38 AM

I had a problem with this kind of thing a while back. It came down to two things. The first was it took a while for the script in the page to run since it was doing a lot of different things (db queries, copying files to servers, untarring things, etc.). The second problem was with the browser. If the browser wouldn't receive any data from the server within a given period of time, about 30 seconds or so, it would give up on loading the page.

I got around the problem by using "flush()" in the page. This would send the buffered portion of the page that had been built to the browser. That was the only change I made and it cleared the problem up. Using this method the browser can wait a lot longer, up to 5 minutes, for the page to completely load before it will give up.

J_Szucs 01-22-2004 04:10 PM

You may be right in that my script does not return anything to the browser until the query is fully completed. Though it could send the page header right at the beginning.

So I will try the flush() command to force PHP to send the page header before the query is run.

However, if it is the browser that times out the connection, why do not I get the timeout when I connect to the server with the same browser but from a local client?

Anyway, thanks for the tip!


All times are GMT -5. The time now is 02:59 AM.