Cannot disable buffering during SSE connection

Maxim Dounin mdounin at mdounin.ru
Thu May 6 03:40:20 UTC 2021


Hello!

On Wed, May 05, 2021 at 02:24:52PM -0700, Anatoliy Malishevskiy wrote:

> I am trying to migrate from Apache2 to NGINX and having issues with SSE
> connections. Everything else is working fine, the regular GET or POST
> requests are getting through successfully.
> 
> But there are 2 critical issues with SSE connections:
> 1) the NGINX holds up responses until the buffer is full
> 2) The NGINX blocks any other requests to the server if SSE is in progress.
> 
> With Apache2 I used to have issue #1, but it was easily resolved with the
> following configurations:
> - *OutputBufferSize 0*
> The issue #2 is really blocking me from using NGINX. Why does the server
> block
> other connections when SSE is in progress?
> How to fix this issue?

[...]

The "fastcgi_buffering off;" should be enough to disable response 
buffering on nginx side.  If it doesn't work for you, this means 
one of the following:

- You've not configured it properly: for example, configured it in 
  the wrong server block, or failed to reload configuration, or 
  not using fastcgi_pass to process particular requests.  I think 
  this is unlikely, but you may want to double-check: for example, 
  by configuring something like "return 404;" in the relevant 
  location to see if it works.

- Some buffering happens in your FastCGI backend.  From your 
  configuration it looks like you are using fastcgiwrap, which 
  doesn't seem to provide any ways to flush libfcgi buffers, so 
  probably it is the culprit.

Your other problem is likely also due to fastcgiwrap, but this 
time incorrect configuration: by default it only provides one 
process, so any in-progress request, such as server-sent events 
connection, will block all other requests from being handled.  You 
have to configure more fcgiwrap processes using the "-c" command 
line argument to handle multiple parallel requests.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list