Sinatra stream(:keep_open) not holding connections open

W. Andrew Loe III andrew at
Wed Dec 5 01:19:28 UTC 2012

I'm running Rainbows with EventMachine and struggling to get it to
keep the connections open.

First, here is my code:

This application works on Thin.

The main loop handles the HTTP request and creates a Celluloid Actor
that hangs out waiting on messages from Redis, when it receives a
message it dispatches it to the stream which EM then pushes out to the
client. Eventually the client will disconnect (this is Server-Sent
Events) and the Actor is torn down.

I want to run under Rainbows! for the hot upgrades and to re-use all
of the wonderful scripts I have for managing my Rails/Unicorn stack.
What I see is the GET handler executed, the Actor spawned, then the
connection is closed and the Actor is terminated. The browser then
reconnects. It doesn't ever have the opportunity to dispatch a message
the Actor doesn't even connect to Redis before it is terminated.
Response times are something like 0.0011 seconds, nothing is being

I'd prefer not to pull in Sinatra::Async, I'd like to know why it
works with Thin out-of-the-box, but not Rainbows!

More information about the rainbows-talk mailing list