0๐
โ
So finally I was able to solve the problem. The issue was due to the buffering of response chunks by Nginx.
Setting the proxy_buffering to off in the Nginx config file solved the issue.
server {
listen 80 default_server;
listen [::]:80 default_server;
location /api {
proxy_pass http://127.0.0.1:3000;
proxy_buffering off;
}
}
I was using Nginx as a reverse proxy server and by default, the proxy buffering is on.
When buffering is enabled, Nginx receives a response from the proxied
server as soon as possible but saves it into the buffers before
returning to the clients. However, When buffering is disabled, the
response is passed to a client synchronously, immediately as it is
received. nginx will not try to read the whole response from the
proxied server.
So essentially that was the reason that I was not receiving my data chunks immediately in the app.
Source:stackexchange.com