New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connection_status and connection_aborted does not work #10106
Comments
Did you mean to report this as actual bug, or as documentation issue? |
hi, ( sorry for delay, did not get the a notification =s ) |
@seltix5 ignore_user_abort(true);
set_time_limit(0);
error_log('start');
while(1)
{
echo "\n";
ob_flush();
flush();
// Did the connection fail?
if(connection_status() != CONNECTION_NORMAL)
{
break;
}
sleep(1);
}
error_log('stop'); Built-in web-server. [Thu Dec 15 14:36:42 2022] 127.0.0.1:52133 Accepted
[Thu Dec 15 14:36:42 2022] start
[Thu Dec 15 14:36:48 2022] stop
[Thu Dec 15 14:36:48 2022] 127.0.0.1:52133 [200]: GET /
[Thu Dec 15 14:36:48 2022] 127.0.0.1:52133 Closing |
Indeed, this works as expected with the built-in Webserver. Which SAPI do you use, @seltix5? Also note that PHP 7.4 is no longer supported, so please check with any of the actively supported PHP versions. |
Checked with php-fpm, also works. |
hello, Server API : LiteSpeed V8.1 Cloudlinux 1.3 |
Well, no output is supposed to be shown in the browser after you've closed the tab. Anyhow, there might be an issue with the lsapi. |
lol, output in the log file after the 'start' line. I got the 'start' line but never got the 'stop' after stoping the request. what should I do then? report to LiteSpeed devs? ( https://www.litespeedtech.com/support/forum/forums/bug-reports.9/ ) |
@seltix5 |
I've tested that on LiteSpeed V8.0.1 (Cloudlinux 1.3) and seems like php process is just killed.
@seltix5 can you run following code? <?php
error_reporting(-1);
ini_set('display_errors', '1');
ignore_user_abort(true);
set_time_limit(30);
register_shutdown_function(function() {error_log('shutdown');});
error_log('start');
for($i = 0; $i < 20; ++$i)
{
echo "\n";
ob_flush();
flush();
// Did the connection fail?
if(connection_status() != CONNECTION_NORMAL)
{
error_log('abort');
break;
}
sleep(1);
}
error_log('loop end'); |
@KapitanOczywisty |
It'll not. TBH
I'm not familiar with LiteSpeed, but from what I've gathered there is an option in server configuration to kill script when client aborts connection. Original script was flawed so we cannot tell for sure if |
hi,
|
What sapi is php running? |
its the same server
|
I just tested on another server that I ask access to do this test and the problem was the same but it does not have PHP 8 available. |
I think the problem may be elsewhere, because you tried |
I published this for testing.
|
Sorry, but I'm afraid to follow unfamiliar links. :) |
Not sure what demoniac virus you can catch just opening the link but sure, i'm just providing whatever I can to help understand the problem and for future reference the code provided may help. |
I understand you.
Right? |
@seltix5 Litespeed is behind nginx, and that complicates things. Sending one character ( |
When PHP engine is not embedded in a web server, like LiteSpeed and FPM, it communicates with web server over an IPC connection, not directly associated with client connection, the connection_status is the status of the IPC connection. |
hi, I try with 5k (code updated #10106 (comment)) but did not work either. there is no solution for this then? :( |
I've installed |
I will try, hopefully they may know what setting is causing the problem. |
With nginx+php-fpm everything works. |
They finally make it work on the server after changing the PHP handler from LSAPI to suPHP. (PHP 7.4.33 - SAPI cgi-fcgi) |
From manual page: https://php.net/function.connection-status
Hi,
I tested this using PHP 7.4 but it does not detect disconnect, I try to stop and close the browser.
The text was updated successfully, but these errors were encountered: