How to set Connection Timeout in .htaccess or php.ini?

serpent_driver

Well-Known Member
#1
To increase timeout for script execution "connection timeout" must be configured in WebAdmin instead of max_execution_time if Apache is used. Is there any way to set "connection timeout" configuration in .htaccess or php.ini?
 

serpent_driver

Well-Known Member
#3
max_execution_time != connection timeout

Increasing max_execution_time value in php.ini or .htaccess does not work with LSWS and connection timeout has to be changed instead, but this can only be done for the entire server.
 

serpent_driver

Well-Known Member
#4
I just found some information about connection timeout is LSWS wiki, so it is possible to control connection timeout with rewrite rules, but this allows "notimeout" only. What I need is to set a time period.
 

NiteWave

Administrator
#5
yes, from following 2 docs collect some related info:

https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:php:run-without-timeouts
or
https://docs.litespeedtech.com/extapp/php/configuration/control/#no-connection-timeout

in .htaccess , there are following directives:

RewriteRule xxx.php - [E=noabort:1, E=noconntimeout:1]
or
SetEnv noconntimeout 1
SetEnv noabort 1

noconntimeout is used to set timeout unlimited, but can't set timeout to a particular value.
its value is set at WebAdmin CP > Configuration > Server > Tuning > Connection Timeout (secs)
 

serpent_driver

Well-Known Member
#9
Testcase? Hm... I try to explain...

I developed a PHP based multi-threading crawler for cache warmup. It works as it should and with all options (similiar to crawler in WP cache plugin, but x-time faster). Everything is okay, but there is still a problem with connection timeout. I can set time for connection timeout in WebAdmin, but I want to control it for specific file/script.

That is what I tried, but nothing works. Timeout is always what I set in WebAdmin

Code:
RewriteCond %{REQUEST_URI} ^\/dir\/assets\.php
RewriteCond %{QUERY_STRING} tab=crawler
RewriteRule .* - [E=noabort:1, E=noconntimeout:1]

Code:
SetEnvIf Request_URI "^\/dir/assets\.php" noabort noconntimeout
 

NiteWave

Administrator
#15
can the crawler run on command line ?
i.e., "php /path/to/assets.php"

if it can, it won't bother with lsws settings include noabort/noconntimeout
 

NiteWave

Administrator
#17
Sorry no time left today, will explain it later. in short, in command line, assets.php will run forever, no unexpected various time outs.
 

serpent_driver

Well-Known Member
#19
For testing and debugging I have the crawler script extracted from main application to get it work in CLI. For this test there is no custom connection timeout in .htaccess defined. The crawler is running without interruption until script it is finished, but only in CLI!

To me, it looks like noconntimeout directive doesn't work in non CLI environment or has no function.
 

NiteWave

Administrator
#20
For testing and debugging I have the crawler script extracted from main application to get it work in CLI. For this test there is no custom connection timeout in .htaccess defined. The crawler is running without interruption until script it is finished, but only in CLI!
great. I think this is the right place/method for your crawler to run.

in general, web server is not suitable for long time running task/script. better to use command line if possible in such case.

also need No CLI support
you can try to make a bit change on your crawler to see if it will work better.
assume the script will crawl 100 pages. there are 2 methods (for example):
1.
Code:
 for($i=1 to 100){ 
      curl_exec(...);
 };
 print "finished 100 urls !";
2.
Code:
 for($i=1 to 100){ 
      curl_exec(...);
      print "finished url[$i]";
      flush();
 };
for main function -- warm up cache, they are same. but 2nd method is more friendly than 1st one. this will keep the connection alive and avoid custom connection timeout
 
Top