Search code examples
phpapachetimeoutconnection-timeout

PHP: script to timeout server connection


I'm trying to test a server timeout case for the front end.

I have create PHP script

set_time_limit(20);

while ($i<=10)
{
     echo "i=$i ";
     sleep(100);
     $i++;
}

with a hope to get server connection time out for requesting that page but instead of that I have got 500 Internal Server error.

Any suggestion for a test server timeout?


Solution

  • Yes, very simple with header();

    <?php 
    
    header("HTTP/1.1 408 Request Timeout");
    exit;