Skip to content


Subversion checkout URL

You can clone with
Download ZIP


connect/read_timeout don't seem to work #127

mislav opened this Issue · 6 comments

2 participants


I'm using :connect_timeout and :read_timeout as params to but they don't seem to have effect.

require 'excon'

# a resource that hangs for 10s before responding
url = 'http://localhost:4567/slow'

conn =, read_timeout: 1, connect_timeout: 1)

puts "requesting..."
started =

resp = conn.request :method  => 'GET'

p resp.status
p resp.headers

puts "done in %5.2fs" % ( - 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?

@geemus geemus closed this issue from a commit
@geemus geemus ensure first read from socket is nonblock
should ensure that timeouts are respected

closes #127
@geemus geemus closed this in 253fdd0

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.