Note that there are some explanatory texts on larger screens.

plurals
  1. POSinatra streaming with Puma?
    primarykey
    data
    text
    <p>I'm trying to leverage Server-Sent Events in my application. I am using Sinatra and the <a href="https://github.com/radiospiel/sinatra-sse"><code>sinatra-sse</code></a> gem. This gem wraps the Sinatra <code>stream :keep_alive</code> call.</p> <p>When running my application on Thin, I have absolutely no problems, and my event stream works as expected. However, when I switched my application to run with Puma everything works, except my <code>sse_stream</code> does absolutely nothing! It just returns a blank page.</p> <p>My stream is set up like so</p> <pre><code>get "/logstream/:server" do if rbcserver = MyApp.servers[params[:server]] sse_stream do |stream| rbcserver.add_web_logger(stream) stream.callback { rbcserver.remove_web_logger(stream) } end else error 404 end end </code></pre> <p>I'm starting Thin like so:</p> <pre><code>@@puma_instance = Puma::Server.new MyApp::WebUI @@puma_instance.add_tcp_listener ip, port @@puma_instance.run </code></pre> <p>Any idea what's going on? Any help would be appreciated.</p> <p>EDIT: some more info This is what cURL gives when running on Puma</p> <pre><code>$ curl -L -b cookies.txt -c cookies.txt -i http://localhost:9001/logstream/myserver HTTP/1.1 200 OK Content-Type: text/event-stream;charset=utf-8 X-Content-Type-Options: nosniff Transfer-Encoding: chunked $ </code></pre> <p>Whereas this is what happens on Thin</p> <pre><code>$ curl -L -b cookies.txt -c cookies.txt -i http://localhost:9001/logstream/myserver HTTP/1.1 200 OK Content-Type: text/event-stream;charset=utf-8 X-Content-Type-Options: nosniff Connection: close Server: thin 1.5.1 codename Straight Razor event: &lt;event name&gt; data: &lt;my data&gt; event: &lt;event name&gt; data: &lt;my data&gt; &lt;continues as more data comes in&gt; </code></pre> <p>EDIT: I should add that my application uses EventMachine at its core, so <code>sinatra_sse</code>'s coupling to EM is most likely not an issue.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload