Welcome! Log In Create A New Profile

Advanced

Re: php server side events [sse]

Maxim Dounin
August 26, 2015 05:10PM
Hello!

On Wed, Aug 26, 2015 at 12:33:48PM -0700, dmiller@amfes.com wrote:

> I have several virtual servers operating with php-fpm perfectly fine.
> Buffering/caching with Wordpress is great. But now...
>
> I'm trying to implement a new site that uses php for server-side events to
> stream live updates to clients. This is, I believe, properly done with an
> infinite loop in php that will send events as they occur. The problem is
> the events seem to be getting buffered and don't appear.
>
> If I write the php program to end after sending an event then it works. If
> I restart php-fpm then it works - at least for a while.
>
> I've tried numerous config options - obviously what I'm trying isn't
> working. Any suggestions?

By default, nginx only starts sending data to a client once it has
a full buffer ready. If you want to stream data immediately,
you have to switch off buffering - either with the fastcgi_buffering
directive, or using the X-Accel-Buffering header in a response.
See http://nginx.org/r/fastcgi_buffering for details.

Additionally, there are some buffering option in PHP. I'm not a
PHP expert, but likely flush() function will help if the problem
is on PHP side, see http://php.net/manual/en/function.flush.php.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

php server side events [sse]

HeavyThumper August 26, 2015 03:36PM

Re: php server side events [sse]

Maxim Dounin August 26, 2015 05:10PM

Re: php server side events [sse]

HeavyThumper August 26, 2015 07:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready