Skip to content
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

improve connection to remote #737

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

improve connection to remote #737

wants to merge 13 commits into from

Conversation

benoitc
Copy link
Owner

@benoitc benoitc commented Feb 22, 2024

This pR track different changes to provide a better UX during connection to remote.

  • happy-eyeball support
  • full support of proxy configuration from the system environnement
  • improve TCP connection reuse: remove constraint on a pool

?report_debug("happy eyeballs, try to connect using IPv6", [{hostname, Hostname}, {port, Port}]),
Self = self(),
Addrs = getaddrs(Hostname),
Pid = spawn_link( fun() -> try_connect(Addrs, Port, Opts, Self, {error, nxdomain}) end),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to spawn here, ,,either wya makes DNS resolution asynchronous.

@benoitc
Copy link
Owner Author

benoitc commented Feb 22, 2024

I should provide a way to bypass DNS resolution and allows the user to force the way it wants to make a connection. Also allow them to choose the preference (for those that have to support the legacy with IPv4).

getaddrs(Hostname) ->
IP6Addrs = [{Addr, 'inet6'} || Addr <- getbyname(Hostname, 'aaaa')],
IP4Addrs = [{Addr, 'inet'} || Addr <- getbyname(Hostname, 'a')],
IP6Addrs ++ IP4Addrs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @benoitc

I wonder if it would make sense to "intersperse" the addresses here like [ipv6, ipv4, ipv6, ipv4, etc.]?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change implements the happy eyeballs strategy to bnring better support of IPv6 for hackney.

It follows the recommendations iof the RFC 8305. https://datatracker.ietf.org/doc/html/rfc8305
This change allows hackney, to handle the no proxy environnement variable properly. This bbring real full support of proxy setup using environnement.
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.

2 participants