• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Question Text/event streaming: Outputs chat answers streamed.

Ultaschall4D

New Pleskian
Server operating system version
Ubuntu 22.04.5 LTS
Plesk version and microupdate number
Plesk Obsidian v18.0.64_build1800241008.13 os_Ubuntu 22.04
Hello everyone!
I am building a chatbot. The chat outputs the answers streamed. Now I'm trying to get it running on a Plesk system. But somehow the text/event streaming is not working. All replies are returned completely, I have already disabled gzip, but also without success. Apache + nginx as reverse proxy server (nginx). How do I get streaming responses?

I have:
output buffering have be disabled in php.ini config
output_buffering = Off zlib.output_compression = Off
Apache gzip module is disabled. You can disable this through Apache config files or by adding the following lines to the `/public/.htaccess` file:s
<IfModule mod_headers.c> RewriteRule ^(.*)$ $1 [NS,E=no-gzip:1,E=dont-vary:1] </IfModule>

... Also, perhabs noting that if you’re using Nginx as a proxy on Apache, the streaming issue might be related to the Nginx configuration?


Can anyone help me?
 
I have the same question. I use in JavaScript EventSource() with response from php as "text/event-stream" and offline in my XAMPP all working fine. Online its not working, its pending and and all replies return at end.

My test case:
PHP:
<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header('Connection: keep-alive');
header('X-Accel-Buffering: no');

while (ob_get_level() > 0) {
    ob_end_flush();
}
if (function_exists('apache_setenv')) {
    @apache_setenv('no-gzip', '1');
}
@ini_set('zlib.output_compression', 'Off');
@ini_set('output_buffering', 'Off');
@ini_set('implicit_flush', 'On');

$counter = 0;
while (true) {
    if (connection_aborted()) {
        break;
    }

    $curDate = date(DATE_ISO8601);
    echo "event: ping\n";
    echo "data: {\"time\": \"{$curDate}\", \"count\": {$counter}}\n\n";

    while (ob_get_level() > 0) {
        ob_end_flush();
    }
    flush();

    $counter++;

    if ($counter > 2) {
        break;
    }
    sleep(2);
}
?>

and in command-line I call
# curl -vN https://www.example.com/test.php

It will only display all outputs once it has run through completely.

I tried nginx setting
location ~* /(test|test2)\.php$ {
proxy_pass https://myip:7081

proxy_buffering off;
proxy_request_buffering off;
proxy_cache off;
gzip off;

add_header Cache-Control no-cache;
add_header Content-Type text/event-stream;
add_header Alt-Svc 'h2=":443"; ma=0';

proxy_read_timeout 610s;
proxy_send_timeout 610s;

proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
not helps. I add for apache:
<Files "test.php">
SetEnv no-gzip dont-vary
</Files>
This did not help either.

What do you have to do here so that a certain script works on the domain with Content-Type: text/event-stream?
Does anyone have experience with this and can help me (and Ultaschall4D)?
 
Back
Top