postrank-labs / goliath

Goliath is a non-blocking Ruby web server framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requests hang on jRuby

JoshuaOSHickman opened this issue · comments

I've been staring at this one for quite some time. Code works in MRI 1.9.3, but all requests hang indefinitely on jRuby. Curl -kv prints "* no chunk, no close, no size. Assume close to signal end" and then stalls out until I control-C the goliath server. At that point the correct response is served and the connection is closed.

The code in use (at the end of the goliath response function) looks like:

[200, {}, Net::HTTP.get(modifiedURL)] # adding in a X-Goliath Proxy header changes nothing

The Net::HTTP request itself returns -- placing it on a separate line lets me print out the result, yet even with it printed to the console, goliath's request never returns.

The synchronous request doesn't seem to matter, as EventMachine requests yield the same problem, but those print out "SOCKET: SET COMM INACTIVITY UNIMPLEMENTED 10" warnings (? I'm not sure what that is, and google seems quite vague).

I'm using:
require 'thread'
require 'goliath'
require 'net/http'
require 'uri'
require 'json'
require 'celluloid'

in case one of those causes this, or is deprecated.

And, as I said, works perfectly on MRI 1.9.3.

Thanks for your time.

Okay, the following file also has the problem, so I guess those details were irrelevant:

require 'goliath'

class Hello < Goliath::API
def response(env)
[200, {}, "Hello World"]
end
end

I've tested on jRuby 1.6.7 and 1.6.6.

I'll pretend that I never saw the Net::HTTP code in there.. you definitely don't want do that.

Appears to be working fine on 1.6.5. Need to get / check on latest JRuby.

Try running the examples from master: ruby examples/hello_world.rb -sv

Yeah, that was mostly there because I've gotten those SOCKET messages
pretty consistently with EM::HttpRequests on jRuby, and there doesn't seem
to be a significant performance penalty under MRI 1.9.3.

I'll check out older versions of jRuby. Thanks for your time.

On Tue, Apr 17, 2012 at 7:19 PM, Ilya Grigorik <
reply@reply.github.com

wrote:

I'll pretend that I never saw the Net::HTTP code in there.. you definitely
don't want do that.

Appears to be working fine on 1.6.5. Need to get / check on latest JRuby.

Try running the examples from master: ruby examples/hello_world.rb -sv


Reply to this email directly or view it on GitHub:
#167 (comment)

"there doesn't seem to be a significant performance penalty under MRI 1.9.3"

I repeat: you definitely do not want to be using Net::HTTP. If you're doing that, you lose the whole point of using Goliath.

On a different note: I can reproduce the problem on 1.6.7 -- looks like something broke in more recent JRuby releases. /cc @headius

Yeah, I think the fact I didn't catch the change being important was
because of my test running too quickly.

Thanks for the advice.

On Tue, Apr 17, 2012 at 7:39 PM, Ilya Grigorik <
reply@reply.github.com

wrote:

"there doesn't seem to be a significant performance penalty under MRI
1.9.3"

I repeat: you definitely do not want to be using Net::HTTP. If you're
doing that, you lose the whole point of using Goliath.

On a different note: I can reproduce the problem on 1.6.7 -- looks like
something broke in more recent JRuby releases. /cc @headius


Reply to this email directly or view it on GitHub:
#167 (comment)

Based on discussion on JRuby repo, the current theory is that the hang behavior is actually an EM bug with respect to newer version of JRuby.. Which doesn't help us much - grr.

Hmm, nevermind JRuby/EM.. this is a bug somewhere in the async_middleware black magic.

The request "hangs" simply because we don't return neither the content length or the "chunked response" indicator. Hence the client just hangs indefinitely, waiting for more data.

@dj2: any ideas here?