Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed

Conversation

carlhoerberg
Copy link

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.

@carlhoerberg
Copy link
Author

@k0kubun k0kubun changed the base branch from trunk to master August 15, 2019 17:33
@casperisfine
Copy link
Contributor

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)
Copy link
Contributor

@kirs kirs Nov 26, 2019

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
@carlhoerberg carlhoerberg force-pushed the net-http-socket-tcp-timeout branch from 77b8734 to 515a669 Compare January 19, 2021 09:58
@carlhoerberg
Copy link
Author

Based on https://bugs.ruby-lang.org/issues/16381 (which was based on this one), but reraising Errno::ETIMEOUT as Net::OpenTimeout

@dentarg
Copy link
Contributor

dentarg commented Jan 19, 2021

Same as ruby/net-http#10? (Related to ruby/net-http#6)

@deivid-rodriguez
Copy link
Contributor

ruby/net-http#10 was merged, so I guess this can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants