<div dir="ltr"><div dir="ltr"><div>Thank you!</div><div><br></div><div>I was able to fix both of these issues.</div><div>However, the fix for the issue #2 is hacky and I am sure there has to be a better way to</div><div>fix this issue. Explained below.</div><div><br></div><div><br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 5, 2021 at 8:40 PM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Wed, May 05, 2021 at 02:24:52PM -0700, Anatoliy Malishevskiy wrote:<br>
<br>
> I am trying to migrate from Apache2 to NGINX and having issues with SSE<br>
> connections. Everything else is working fine, the regular GET or POST<br>
> requests are getting through successfully.<br>
> <br>
> But there are 2 critical issues with SSE connections:<br>
> 1) the NGINX holds up responses until the buffer is full<br>
> 2) The NGINX blocks any other requests to the server if SSE is in progress.<br>
> <br>
> With Apache2 I used to have issue #1, but it was easily resolved with the<br>
> following configurations:<br>
> - *OutputBufferSize 0*<br>
> The issue #2 is really blocking me from using NGINX. Why does the server<br>
> block<br>
> other connections when SSE is in progress?<br>
> How to fix this issue?<br>
<br>
[...]<br>
<br>
The "fastcgi_buffering off;" should be enough to disable response <br>
buffering on nginx side.  If it doesn't work for you, this means <br>
one of the following:<br>
<br>
- You've not configured it properly: for example, configured it in <br>
  the wrong server block, or failed to reload configuration, or <br>
  not using fastcgi_pass to process particular requests.  I think <br>
  this is unlikely, but you may want to double-check: for example, <br>
  by configuring something like "return 404;" in the relevant <br>
  location to see if it works.<br>
<br></blockquote><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- Some buffering happens in your FastCGI backend.  From your <br>
  configuration it looks like you are using fastcgiwrap, which <br>
  doesn't seem to provide any ways to flush libfcgi buffers, so <br>
  probably it is the culprit.<br></blockquote><div><br></div><div>You were right pointing out to the fastcgiwrap, it was keeping <br></div><div>buffers until the application is terminated or buffer is full.</div><div>I fix this issue by adding the following lines into the /location:</div><div><br></div><div>          ### When set (e.g., to ""), disables output fastcgiwrap buffering.</div><div></div><div>              ### MUST be set if SEE used<br>           <b>fastcgi_param                  NO_BUFFERING "";</b><br><br>                ### When buffering is disabled, the response is passed to a<br>           ### client synchronously, immediately as it is received.<br>              ### Nginx will not try to read the whole response from the<br>            ### FastCGI server.<br>           ### MUST be set if SEE used<br><b>          fastcgi_buffering               off;</b></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Your other problem is likely also due to fastcgiwrap, but this <br>
time incorrect configuration: by default it only provides one <br>
process, so any in-progress request, such as server-sent events <br>
connection, will block all other requests from being handled.  You <br>
have to configure more fcgiwrap processes using the "-c" command <br>
line argument to handle multiple parallel requests.<br></blockquote><div><br></div><div>You were right here. I had to provide the "-c4" parameter, for example, to</div><div>fcgiwrap process. But I could not find an easy way to set this parameter,</div><div>I had to hack /etc/init.d/fcgiwrap and change DAEMON_OPTS variable and <br></div><div>force the script to stop then start the service again with new parameters when I type:</div><div>> sudo /etc/init.d/fcgiwrap reload</div><div><br></div><div>Do you know any better way to provide this -c4 parameter to fcgiwrap?</div><div>Or I have to create my own fcgiwrap script just only to enable multiple parallel requests handling?</div><div><br></div><div>Thanks<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>Anatoliy Malishevskiy<br></div>YumaWorks, Inc.<br></div></div></div></div></div>