[josm-dev] IPv6 problems

Philip Homburg pch-osm-josm-dev at u-1.phicoh.com
Fri Jan 1 20:49:26 UTC 2016


> > - Ideally, operating systems should ship with a happy eyeballs implementati
> on
> >  in the C library. I don't know any that does. It is not such a great idea
> >  for applications to roll their own. Mostly because you may want knobs to
> >  configure things system wide.
> 
> For C there probably are libraries.

Yes, but if they are non-standard it is unlikely that java will pick them up.
And it should be a standard library for the OS. Having multiple libraries
increases the pain if you need to configure something.

> > - All applications should loop over all addresses returned by getaddrinfo.
> >  There is simply no excuse not to. If java makes it impossible to iterate
> >  over all addresses that it is java that is horribly broken.
> 
> And it's not so easy to handle multiple connects. You can either
> optimize for speed (open multiple connections parallel) or for load
> (open one after the other) or ignore it (single connect) or randomly
> choose an address (e.g. what postfix does). All of these methods
> have advantages and disadvantages and depend on the application.

It is really simple. An application should do nothing more than trying each
address in turn in the order returned by getaddrinfo. Either connect(2)
succeeds and you are done or there is a failure and you try the next address.

Trying to open connections in parallel enters happy eyeballs teritory.
Experience shows that it is hard to get right, so it is better to leave that
to a system library.

Note that happy eyeballs is only required if the first address causes a
timeout most of the time. Otherwise, it is much better have have to sit
through the occasional timeout than the have an application that gives up
after trying just the first address.

Trying only one address has been bad practice since before IPv6 was even
invented.

Of course, tweaking /etc/gai.conf to prefer IPv4 over IPv6 is also an option.
(Assuming java uses getaddrinfo under the hood)



More information about the josm-dev mailing list