I'm using :connect_timeout and :read_timeout as params to Excon.new but they don't seem to have effect.
# a resource that hangs for 10s before responding
url = 'http://localhost:4567/slow'
conn = ::Excon.new(url.to_s, read_timeout: 1, connect_timeout: 1)
started = Time.now
resp = conn.request :method => 'GET'
puts "done in %5.2fs" % (Time.now - started)
The request takes 10 seconds and then finishes normally. No exception is thrown, but should be after 1s.
Hmm, not sure off hand. I'm not seeing any obvious problems in the way the code is trying to define timeouts and the like. What ruby and operating system are you using?
ensure first read from socket is nonblock
should ensure that timeouts are respected
I think the read timeout worked before as long as the timeout occured in the body, but not if it was at the beginning or during the headers. This is due to some difference in how the status/header lines are parsed (for performance reasons). I've changed it so that at least the initial read from the socket is the same as the body reads, which should mean that if the initial portions hangs (as in your case) it should timeout as expected.
Yep, it seems to work. The only problem now is that I get the Excon::Errors::SocketError instead of Excon::Errors::Timeout. I have to read the message of the exception to figure out that SocketError was due to a timeout.
@mislav - ah, good. Thanks for the feedback I'll try to correct the message. Then I just need to figure out how to unbreak the build for jruby and it should be releasable...
@mislav - this should fix the error type: d862a33
Still need to figure out whats up with the jruby build though, unfortunately...
Require excon 0.14.1 which fixes timeout issue