0

I was trying to implement SSE with Rails using a Puma server.

I followed this post, which guides SSE implementation with partial hijacking. For testing purposes what I did differently is instead of a while loop I loop for definite times for writing to the stream. Locally the implementation works great. Then I deployed it to my staging server which sits behind a Nginx.

In the staging server, the implementation's behavior is a bit different. My observations were as follows in the staging server:

If I was doing sth like:

sse = SSE.new(...)
5.  Times do
  sse.write(...)
  sleep 2
end

then the request remained in a pending state for about 10 seconds. and only then do I get the results altogether which in my opinion is not the correct behavior. The same code is in my local environment; I received a stream every 2 seconds for 5 times.

This got me confused as to why I got the stream altogether and not in a sequential manner in the staging. If anyone with experience could shed some light on this, please??!

I followed the accepted answer for this post for my nginx configuration.

googlesnet
  • 85
  • 9

0 Answers0