408 error

Discussion in 'PHP' started by BCata, Nov 20, 2010.

  1. BCata

    BCata New Member


    I have a script that requires some intensive calculations every now and then. On apache, I simply use set_time_limit(0). But when doing this on litespeed it doesn't do anything and I get the 408 error ( as shown below ). If I use ob_flush() every few secs inside the script it works properly, but cannot change all the long running scripts to include a flush command. Is there a way to set "Connection Timeout" from within a php script? Because I do not want to raise that value for the entire server, but only for a select few files.

    "408 Request Time-out

    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'."
  2. NiteWave

    NiteWave Administrator

    As a quick solution, increase Server->Tuning->Connection Timeout (secs)

    php in suExec mode or not? are you on a shared hosting or your own VPS?
  3. BCata

    BCata New Member

    I know about Server->Tuning->Connection Timeout (secs). But that would increase the security risk for my clients. I only really need an increased timeout for a few files, some executed by CRON and some executed manually ( as an example, I have a file that checks email addresses... That takes a while to query each domain and check response time and so on. Execution time is often around 10 mins to process everything. That file runs once a week at most. ).

    PHP suEXEC is used ( at least it is reported in WHM "Apache suEXEC" ON ). I have a VPS from WiredTree.
  4. xing

    xing LiteSpeed Staff

    First, the webserver should never let any connection idle beyond the set connection timeout limit. Having no timeout is a much more of a security/ddos risk. Let say you have all your 20 backend lsapi php processes behind litespeed doing heavy calculation for non-specified amount of time with no timeout control and zero 0 lsapi php processes left to handel the real traffic. Just imagine the outcome.

    You should not call this long running script through a web server wether its LiteSpeed or Apache. Call it directly via crond, fcrond, etc. There you can have the script run to infinity without affecting the operation of the website itself.

    Calling a long running script behind a webserver is fundamentally the wrong way to do things.

    This might have "worked" with Apache but if anyone finds out the link to this script, then anyone can bring down your website.
  5. BCata

    BCata New Member

    I am a programmer with almost 10 years of experience. I know about the pros and cons on running such long processes. First, the file is protected so only the admin can run it. Second it is protected to only run once every week, no matter how many times you click on it. So it cannot bring the server down.

    The script needs to run when I import large lists of emails ( around 500.000 emails per list ). It needs to check every email if it is valid ( proper checking with string validation, domain ping and mx record check ). The thing is, some are invalid and then the script has to wait 2-3 second for the internal check timeout. 2-3 seconds times 1000 takes a long time just to wait. That is the actual issue and script. That file cannot run under CRON since I need the results right after the upload.

    So my question stands: is there a way to increase connection timeout limit from the PHP script on a litespeed server, like it is possible on Apache?
  6. mistwang

    mistwang LiteSpeed Staff

    set_time_limit(0) only change PHP internal limit, has nothing to do with any web server, including apache and LSWS. Apache is likely to have a very long connection timeout, so it works if you change set_time_limit(), it does not mean that the function really did anything to Apache.

    If you want it work like Apache, you have to increase the connection timeout.

Share This Page