Skip to content

Try other addresses resolved via DNS if the first one fails #417

Open

Description

@nightpool

When available, ipv6 addresses seem to be preferred to IPv4 ones. However, in practice, v6 addresses are much less reliable. This is a pretty big problem for the Mastodon project, since it often gets urls that are served by dual-stack instances with dubious ipv6 setups, and so it ends up timing out on a lot of them, causing issues verifying posts.

It would be very useful if we could configure somehow to prefer ipv4 addresses to ipv6 addresses. I don't think this is an issue with the standard Net::HTTP stack, or with curl, so it would be great to match those behaviors.

see also mastodon/mastodon#3762

Activity

  1. tarcieri commented on Jun 29, 2017

    @tarcieri
    Member

    The preference ordering comes from DNS. http.rb is not doing anything unusual here, at all, it leans on core Ruby to resolve DNS and pick a host:

    https://github.com/httprb/http/blob/master/lib/http/timeout/global.rb#L26

    That said, what? No. We're using the system resolver, and we are absolutely not going to introduce special logic to second guess it by doing things like prioritizing IPv4 over IPv6, sorry.

  2. ClearlyClaire commented on Jun 29, 2017

    @ClearlyClaire

    It is not so much about doing anything special with the DNS requests or prioritizing IPv4 over IPv6, but rather trying other returned addresses if the first picked one fails. I am not sure there is any standard for that, but it is pretty common to try several addresses whenever a DNS query returns multiple A/AAAA records when the first try fails.

  3. changed the title [-]Connecting to servers that advertise a non-working IPv6 address fails[/-] [+]Try other addresses resolved via DNS if the first one fails[/+] on Jun 29, 2017
  4. tarcieri commented on Jun 29, 2017

    @tarcieri
    Member

    Okay, that's a valid concern. Reopened the issue and updated the title to reflect that

  5. ixti commented on Jun 29, 2017

    @ixti
    Member

    My 2 cents. Once valid (working) address found - it should probably be cached at least for the given TTL (probably can be configured) so that next request to the same host will "shortcut" on trying those we know not working

  6. bortzmeyer commented on Jul 17, 2017

    @bortzmeyer

    @nightpool I fully agree with @ThibG, it is not an IPv6 issue but, just for information: Mastodon does not do any specific treatment, such as preferring IPv6 over IPv4 or the opposite. It is entirely up to your operating system (on Linux, you can change the behaviour by editing /etc/gai.conf.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions