0

I want to test that my client times out when a web server does not respond in time. I thought I could do this by making a PHP page that never completes the response, yet I don't want it to hog all the server's resources. I.e. this is not an option:

<?php while (true);?>

Suggestions?

Nilzor
  • 18,082
  • 22
  • 100
  • 167
  • `` will work? Although normally you will reach the maximum execution time (30 sec) in PHP, so it won't really work that way unless you can edit that. – Francisco Presencia May 13 '13 at 12:34
  • *sidenote:* you can config browser timeout to save you some time on waiting. Try changing settings of Firefox : `network.http.connect.timeout` and `network.http.connect.timeout`. For other browsers, read more here: http://stackoverflow.com/questions/1342310/where-can-i-find-the-default-timeout-settings-for-all-browsershttp://stackoverflow.com/questions/1342310/where-can-i-find-the-default-timeout-settings-for-all-browsers – Raptor May 13 '13 at 12:55

3 Answers3

3

You could try:

<?php
set_time_limit(0); /* No time limit */
sleep (1000);
?>
Francisco Presencia
  • 8,732
  • 6
  • 46
  • 90
0

try this

<?php 
   while (true){
         sleep (10000); 
   } 
?>
Dima
  • 8,586
  • 4
  • 28
  • 57
-2
<?php while (true) sleep (10); ?>

This will work as long as the server has a timeout set.

samayo
  • 16,163
  • 12
  • 91
  • 106
Shamoon
  • 41,293
  • 91
  • 306
  • 570