mdn / dom-examples

Code examples that accompany various MDN DOM and Web API documentation pages
https://developer.mozilla.org/en-US/docs/Web/API
Creative Commons Zero v1.0 Universal
3.48k stars 1.81k forks source link

SSE example does not work in Firefox. #24

Closed timschofield closed 7 months ago

timschofield commented 6 years ago

I have set this example up on my localhost with nginx running (I have made the change from the Readme.md file) and it runs fine in Chromium but nothing happens in Firefox, no error messages just the button. I have tried it in v60 and the nightly build v62 with the same result.

Any ideas?

Tim

chrisdavidmills commented 6 years ago

Hrm, this is a bit of a worry. So you did make the fastcgi_buffering change.

I've not got nginx set up to test, but I just tried it again in the latest Firefox with Apache (via MAMP), and it worked fine.

timschofield commented 6 years ago

Ok. This is the relevant section from my config file:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php7.0-cgi alone:
    # fastcgi_pass 127.0.0.1:9000;
    # With php7.0-fpm:
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_read_timeout 3000;
    fastcgi_buffering off;
}

this is the snippets file that is included by the above:

regex to split $uri to $fastcgi_script_name and $fastcgi_path

fastcgi_split_path_info ^(.+.php)(/.+)$;

Check that the PHP script exists before passing it

try_files $fastcgi_script_name =404;

Bypass the fact that try_files resets $fastcgi_path_info

see: http://trac.nginx.org/nginx/ticket/321

set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php; include fastcgi.conf;

I tried in Opera as well as Chromium and they both worked. I will have a go at setting up an apache server and see if I can narrow it down.

jaesoni commented 3 years ago

Firefox issue for me as well. But in my case it asks to download the PHP file instead. Works in Chrome. I'm able to able other php files in all browsers

PHP 7.2.24-0ubuntu0.18.04.10 (cli) (built: Oct 25 2021 17:47:59) ( NTS ) Server version: Apache/2.4.29 (Ubuntu)

dipikabh commented 1 year ago

Link to the code file: https://github.com/mdn/dom-examples/blob/main/server-sent-events/sse.php

bsmth commented 7 months ago

Thanks a lot for reporting this one. I can confirm this works as expected on Nightly and stable Fx releases:

image

steps to reproduce:

git clone https://github.com/mdn/dom-examples.git
cd dom-examples/server-sent-events
php -S localhost:8000

For nginx config, this has been fixed in https://github.com/mdn/dom-examples/pull/91

I'm going to close as fixed, but if you think I've missed something, feel free to reply and let me know!