-
Notifications
You must be signed in to change notification settings - Fork 3k
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
inet6 to inet fallback in networks without ipv6 support #8548
Comments
In place of a "ping": I would also happily work on implementing happy eyeballs into Erlang! Related issues / discussions / projects:
|
I believe built-in happy eyeballs implementation would be a huge win for the ecosystem. 👍 |
Yes! |
I believe that the idea is that gen_tcp (and gen_udp, gen_sctp) should be "close to the metal". I my memory is correct the inets (httpd and httpc) had a similar config option (inet6fb4 or something like it). I do not know if ssl has this feature. 'socket' is very much "close to the metal". But gen_tcp could maybe be considered to be a layer that |
This is the kind of feature that sits between OTP and application I think. It makes sense to have it in OTP because many would use it, but not all network connections require it either. It could be a separate open source project, but then who has the will and the bandwidth to maintain it? Happy Eyeballs is also tricky in that it pretty much requires connecting via 4/6 concurrently. The The alternative is building on top of If we could "upgrade" a |
FWIW, I started working on https://github.com/ruslandoga/happy_tcp and will be trying to implement Happy Eyeballs by using
I haven't looked into
So far, happy_tcp seems to work without any changes but it would be nice if inet_tcp_backend "behaviour" could connect to multiple addresses instead of just one, then my hack of passing a list of addresses could go away. But my ideal would be having |
The OTP changes are needed to keep the same interface, i.e. once the connection has succeeded you use |
When `DATABASE_USE_IPV6` is enabled, but the provided DB URL has no resolvable IPv6 address (no AAAA record), naively fallback to IPv4. A more general discussion on this fallback behaviour for Erlang's networking stack can be found here erlang/otp#8548 Ideally we would be able to handle this sort of fallback directly with Postgrex, and it used to have the possibility to specify multiple endpoints with different options that it would try sequentially, but it is no longer supported. I have opened an issue to see if there is a potential solution to this that can be supported by Postgrex directly elixir-ecto/postgrex#730 Perhaps once we are happy with both IPv6 and IPv4 being supported out of the box we can remove the `DATABASE_USE_IPV6` option and always default to supporting it, but I think it's safer to explore this a bit further. This PR introduces a naive fix that does not cover all possible failure and fallback cases, but unblocks the basic case of AAAA records missing while also supporting IPv6.
👋 everyone :) I ran into this issue again today. I wonder if it would be OK for me to explore a possible solution and PR it? I would be super honored to contribute at least something to the great OTP!.. And I have a lot of free time these days :) |
Sorry if that's a dumb question, but why isn't |
It doesn't always work, and making it work well requires algorithms like Happy Eyeballs, not just a naive fallback. Here's a recent post I saw on HN today about some of the possible problems: https://techlog.jenslink.net/posts/ipv6-is-hard/ |
👋
Is your feature request related to a problem? Please describe.
Not sure yet. First I'd like double check if
gen_tcp:connect
andssl:connect
withinet6
option are supposed to fallback toinet
when IPv6 connection is not successful. And if it's not supposed to work this way, I'd like to request this feature!Right now I'm not able to make this sort of fallback work. Here're some examples from Fly.io dual-stack machine and from an IPv4-only container running on AWS EC2. I'm using IPv4-only and IPv6-only hosts from http://dual.tlund.se
From Fly.io Machine
Connecting to IPv4-Only Host works with default
inet
optionBut fails when
inet6
option is providedipv6_v6only
doesn't HelpDefault options (
inet
) don't work with IPv6-only hostinet6
works with IPv6-only hostFrom IPv4-only container on AWS EC2
No fallback to
inet
Describe the solution you'd like
inet6
would fallback toinet
automatically when needed so that providinginet6
option would always increase the chance of a successful connection.Describe alternatives you've considered
Some Elixir libraries perform a manual fallback from inet6 to inet like Mint and some other libraries like Postgrex allow a list of endpoints to be provided for connection attempts.
Additional context
Relevant discussion (where this question originated): phoenixframework/phoenix#4289 (comment)
The text was updated successfully, but these errors were encountered: