Jump to content

Recommended Posts

I'm trying to proof a comet style page and to start it up I thought I would set a simple counter in PHP to output 0->3 with a one second delay between each output and flush it to screen each second.  Problem is nothing I have tried has actualy managed to flush the buffer out.  It just sits there with the loading spinner and after 4 seconds dumps the lot onto the screen at once.  I have been diging about and have set the nginx config to the following:

user www-data;

worker_processes  1;



error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;



events {

    worker_connections  1024;

     multi_accept on;

}



http {

    include       /etc/nginx/mime.types;



    access_log    /var/log/nginx/access.log;



    sendfile        on;

    tcp_nopush     on;



    #keepalive_timeout  0;

    keepalive_timeout  65;

    tcp_nodelay        on;



#----------------------------------------------

#    fastcgi_keep_conn on;

    proxy_buffering off;

    gzip off;

#----------------------------------------------

    gzip_disable "MSIE [1-6]\.(?!.*SV1)";



    include /etc/nginx/conf.d/*.conf;

    include /etc/nginx/sites-enabled/*;

}

I had to comment out the fastcgi_keep_con on; as this wasn't recognised.

 

The following is the PHP page.

<?php



ini_set('zlib.output_compression', 'Off');

ini_set('output_handler',"");

ini_set('implicit_flush',1);

set_time_limit(0);



ob_start();

header("Cache-Control: no-cache, must-revalidate");

flush();

ob_flush();

 

    for ($i=0;$i<4;$i++) {

      echo "$i <br>";

      ob_flush();

      flush();

      sleep(1);

    }



ob_end_clean();

?>

Any ideas what I'm missing here?

Link to comment
https://forums.phpfreaks.com/topic/281631-cant-flush-buffer-with-nginx/
Share on other sites

well I am deffinately open to suggestions on alternatives, since none are forthcoming on making this work.  I wonder why there are so many resources on COMET applications using this setup which completly ignore that it's not supposed to be done....damn internet :

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.