• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue PHP connection_status and connection_aborted always 0

AlwinLubbers

New Pleskian
Server operating system version
Debian 11.8
Plesk version and microupdate number
Plesk Obsidian v18.0.56_build1800231106.15
Hi there, I'm trying to setup an EventSource stream for server side events with PHP.

My script checks whether the connection is still active using connection_status() and connection_aborted(). It works flawlessly on my Mac with Apache 2.2.4.57 using default configs. It doesn't work on my webserver with Plesk 18.0.56 using default configurations. Both connection_status() and connection_aborted() will always be '0', telling my script that the connection is still active, even if the client is not connected anymore. Removing Nginx and going with Apache only did not work.

I've tried both PHP 8.2.12 Dedicated FPM served by Apache and Dedicated FPM served by Nginx. Both give the same result, with the Nginx handler giving an additional error:
Code:
1327235#0: *122924 upstream timed out (110: Connection timed out) while reading response header from upstream

These are the headers that are being sent by my PHP script:
PHP:
ignore_user_abort(true);
set_time_limit(0);

header('X-Accel-Buffering: no');
header('Connection: keep-alive');
header('Cache-Control: no-cache');
header('Transfer-Encoding: chunked');
header('Content-Type: text/event-stream');
header('Access-Control-Allow-Origin: *');

Which are the right headers to get SSE to show up. The code that handles the connection looks like:
PHP:
while (true) {
    echo "data: \n\n";
    ob_flush();
    flush();
    set_time_limit(0);

    if(connection_status() != 0 || connection_aborted() != 0) break;
}

There is almost no info available about similar problems while using SSE in combination with Plesk, since most use socket instead of eventsource.

I'm happy to provide more info if needed. Thanks!
 
Back
Top