Sinatra stream(:keep_open) not holding connections open
W. Andrew Loe III
andrew at andrewloe.com
Wed Dec 5 02:16:15 UTC 2012
I've pushed a very very stripped down example that just echos the time.
$ bundle install
$ foreman start rainbows
$ foreman start thin
Rainbows listens on 5000 and hangs up immediately.
Thin listens on 5001 and keeps the connection open, you'll see the
time in your browser.
On Tue, Dec 4, 2012 at 5:44 PM, Eric Wong <normalperson at yhbt.net> wrote:
> "W. Andrew Loe III" <andrew at andrewloe.com> wrote:
>> I'm running Rainbows with EventMachine and struggling to get it to
>> keep the connections open.
>> First, here is my code: https://gist.github.com/c33598db8a113b574165
> I'll take a closer look later today.
> Can you use a public gist (or any other public git repo) instead of a
> private one? Private gists make no sense for public bug reports.
>> 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.
> Can you reproduce the issue with a stripped down application that
> does not depend on Redis? How about one that does not depend on
>> 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!
> I would too! I wasn't aware of stream(:keep_open) until now.
> I'll check it out soon.
> Rainbows! mailing list - rainbows-talk at rubyforge.org
> Do not quote signatures (like this one) or top post when replying
More information about the rainbows-talk