Zbatery/Rainbows keepalive problem?

Jake Douglas jakecdouglas at gmail.com
Sun Nov 28 00:30:18 EST 2010


On Sat, Nov 27, 2010 at 1:55 PM, Jake Douglas <jakecdouglas at gmail.com> wrote:
> On Sat, Nov 27, 2010 at 12:50 AM, Eric Wong <normalperson at yhbt.net> wrote:
>> Jake Douglas <jakecdouglas at gmail.com> wrote:
>>> On Wed, Nov 24, 2010 at 2:14 PM, Eric Wong <normalperson at yhbt.net> wrote:
>>> >
>>> > The normal Rails "render" path already seems[1] to add Content-Length;
>>> > are you doing something else to send responses from Rails?
>>>
>>> I am not doing anything special to send responses from Rails, only 'render'.
>>>
>>> I can see in my browser that keep-alive is set, and Content-Length is
>>> also set. It looks like the first couple requests finish quickly, and
>>> then the remaining take an additional 5 seconds each. It seems the
>>> browser is hanging for the default keep-alive timeout of 5 seconds on
>>> each request before proceeding. This happens with different browsers.
>>
>> Interesting.  I rarely actually do anything with a full web browser,
>> but I can confirm keepalive works as expected with curl...  Is there
>> anything in your error logs such as exceptions being thrown by your
>> app?
>>
>> Can anybody else reproduce this behavior Jake is seeing?
>>
>>> Is there additional information I can provide to give better insight
>>> into why this is happening?
>>
>> tcpdump or similar output would be useful, thanks!
>>
>> --
>> Eric Wong
>> _______________________________________________
>> Rainbows! mailing list - rainbows-talk at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rainbows-talk
>> Do not quote signatures (like this one) or top post when replying
>>
>
>
> It looks like the first issue is that by default Rails does not
> actually use Rack::ContentLength or set the Content-Length itself.
>
> The next issue is this bug, where Rack::ContentLength has some
> conditions that cause it to skip handling of the
> ActionDispatch::Response object from Rails. (ActionDispatch::Response
> < Rack::Response)
> http://rack.lighthouseapp.com/projects/22435/tickets/95-responsefinish-and-contentlength
>
> Fixing and enabling Rack::ContentLength seems to fix the issue for a
> single request to Rails from curl, but I am still getting the problem
> in my browser(s). Zbatery logs say that the request finishes quickly
> but the browser hangs for 5 seconds at a time. It is unclear to me
> what the cause is. I will try to do some more research and let you
> know the result.
>
> Thanks
>

After some more experimentation, it looks like the browser(s) fail to
close the connection after receiving the responses. Zbatery then waits
until the keepalive_timeout has expired, closes it, and accepts the
next connection. I gave the same application a try using Thin with
keep-alive and everything works fine. I spent a lot of time trying to
identify differences between the two, but the only useful thing I
managed to find is that the browser side never sends a FIN-ACK when
talking to Zbatery. For some reason, the browser doesn't think it's
finished. Any suggestions appreciated.

Thanks


More information about the rainbows-talk mailing list