Sinatra stream(:keep_open) not holding connections open

Eric Wong normalperson at yhbt.net
Wed Dec 5 01:44:54 UTC 2012


"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
Celluloid?

> 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
> done.
> 
> 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.


More information about the rainbows-talk mailing list