Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to timing process in php for request Timeout

Tags:

php

My PHP code is timing out with the following error:

This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'

I'm not sure why this is happening. This is my code:

if(!in_array($name,$names)){
    mysql_query("INSERT INTO `tbl` (`name`, `time`, `link`) VALUES ( '$name', '$time', '$link');");
} else {
    mysql_query("UPDATE `tbl` SET `time` = '$time', `link` = '$link' WHERE `pishkhan`.`name` = $name;");
    echo $name.'<br/>'; 
}
file_put_contents('test/albums/news/'.$name.".jpg", fopen($link, 'r'));
like image 202
ttrasn Avatar asked Apr 14 '15 09:04

ttrasn


People also ask

What is the use of session timeout in PHP?

Session timeout can be customized, to make the user’s page inactive after a fixed time. Starting session: The PHP, session_start () function is used to start a session in the web page. Session variables: After the start of the session, session variables can be created for future use.

How do I set session timeout for a specific time period?

First, set session.gc_maxlifetime to the desired session timeout, in seconds. E.g. if you want your sessions to timeout after 30 minutes, set session.gc_maxlifetime to 1800 (60 seconds in a minute * 30 minutes = 1,800 seconds). What this does is ensure a given session file on the server can live for at least that long.

How do I increase the timeout in a PHP script?

Increasing the timeout in php.ini by adding a line: max_execution_time = {number of seconds i.e. 60 for one minute}. Increasing the timeout in your script itself by adding: ini_set('max_execution_time','{number of seconds i.e. 60 for one minute}');

How do I change the PHP timeout settings in IIS?

Step 2) Click on the main connection (not specific to any particular domain). Step 3) Under the IIS section, find FastCGI Settings (shown below). Step 4) Therein, right-click the PHP application and select Edit.... Step 5) Check the timeouts (shown below).


1 Answers

As I stated in my answer here, this particular error message is generated by the LiteSpeed web server (a faster replacement for Apache). It has a special feature whereby it cancels long-running scripts (even those that use set_time_limit()). To disable this, you need to put the following in your .htaccess file in the root of your site.

RewriteEngine On
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]
like image 69
Simon East Avatar answered Oct 13 '22 20:10

Simon East