Problem
Some PHP scripts should run for long periods without interruption but appear to hang or return the error "Connection timeout".
Cause
When a script returns nothing for a long time, it can trigger a timeout on the server that closes the client connection. This is done to prevent badly written PHP scripts from crashing the server.
Also, when a user closes a connection (by closing a window, for example), the web server (LiteSpeed) interrupts the processing of this PHP script by stopping the PHP process. This is to avoid wasting system resources and to prevent certain types of DoS attacks. In some cases, it is better not to abandon the PHP script, regardless of whether the connection has been closed or not.
For example, the built-in WordPress cron jobs start a background job by sending a request to wp-cron.php and then immediately closing the connection without waiting for a response. However, for the cron job to complete, the web server must keep the PHP engine running without interruption.
To get the functionality you want from your web applications, you may need to prevent the connection from expiring and closing. This can be avoided by using the noconntimeout and noabort variable of LiteSpeed.
Solution
Add the following line to the .htaccess file:
RewriteRule .* - [E=noabort:1, E=noconntimeout:1]