PHP/Apache after 32 seconds sleep = no response

PHP 7.4 on Apache
When sleeping for over 31 seconds Apache does not display the last message. I have added various directives in the script to avoid the problem without success.
Here is the script...
<?php
declare(strict_types=1);
error_reporting(-1);
ini_set('display_errors', 'true');
ini_set('max_execution_time', '300');
ini_set('max_input_time', '300');
ini_set('memory_limit', '256M');
ini_set('session.gc_maxlifetime', '3600');
set_time_limit(0);
echo 'Current PHP version: ' . phpversion() . '<br>';
$delay=32; // enter any number over 31
ob_start();
$buffer = str_repeat(" ", 214096)."\r\n<span></span>\r\n";
echo $buffer."Waiting $delay seconds for the last message...<br>";
ob_flush();flush();ob_end_flush();
sleep ($delay);
echo $buffer."The last message!<br>";
exit;
?>
UPDATE 1: I just decided to simplify the script and now I get '500 Internal Sever Error' at 32 seconds. Here is the simplified script:
<?php
declare(strict_types=1);
error_reporting(-1);
ini_set('display_errors', 'true');
ini_set('max_execution_time', '300');
ini_set('max_input_time', '300');
ini_set('memory_limit', '256M');
ini_set('mssql.connect_timeout', '300');
ini_set('mysql.connect_timeout', '300');
ini_set('session.gc_maxlifetime', '3600');
set_time_limit(0);
echo 'Current PHP version: ' . phpversion() . '<br>';
$delay=32; // enter any number over 31
echo "Waiting $delay seconds for the last message...<br>";
sleep ($delay);
echo "The last message!<br>";
exit;
?>
UPDATE 2: I just found out that this is a FCGI timeout. Virtualmin says:
When PHP scripts are run using FCGId mode, this field sets the maximum time each script call can run for.
I went to my Virtual Server>Website Options>Maximum PHP script run time and changed it and now it works.
However, I cannot find where Virtualmin has applied the change. I am still searching the whole server for something called: FcgidIOTimeout
If anyone knows, I will accept their answer.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.