-
Notifications
You must be signed in to change notification settings - Fork 5.4k
net/http: use connect_timeout in Socket.tcp #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Does the merge of https://bugs.ruby-lang.org/issues/15553 makes this PR viable now? |
lib/net/http.rb
Outdated
begin | ||
TCPSocket.open(conn_address, conn_port, @local_host, @local_port) | ||
Socket.tcp(conn_address, conn_port, @local_host, @local_port, | ||
connect_timeout: @open_timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR!
With the patch from https://bugs.ruby-lang.org/issues/15553, I think the arguement should be resolv_timeout: @open_timeout
.
Otherwise, I can confirm this patch working on Linux. I'd be really interested in seeing it merged.
If you're looking for a way to write a test for this, something like this should work: https://gist.github.com/kirs/5f711099b23ddae7a87ebb082ce43f59
Based on https://bugs.ruby-lang.org/issues/16381 but rerasing Errno::ETIMEDOUT as Net::OpenTimeout
77b8734
to
515a669
Compare
Based on https://bugs.ruby-lang.org/issues/16381 (which was based on this one), but reraising |
Same as ruby/net-http#10? (Related to ruby/net-http#6) |
ruby/net-http#10 was merged, so I guess this can be closed? |
Instead of wrapping TCPSocket.open with a Timeout.timeout, we rely on the kernel's socket connect timeout, avoiding a temporary thread just for the timeout.