Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] persistent connection failure when v6 is not working

Roger Light <roger@xxxxxxxxxx> writes:

> The bridges use getaddrinfo() to determine what to connect to, and
> will try whichever of IPv4 and IPv6 is offered first. If that fails it
> should go on to the next address. Looking at it though, it's possible
> if the first connection attempt doesn't immediately fail but is still
> pending because it is a non-blocking socket, then we could end up in
> the situation that getaddrinfo always returns the same address first,
> so we try to connect, it half completes so we drop out of the
> getaddrinfo loop, then it later fails and we retry and get the same
> failing address.

Thanks for the analysis.  This is very plausible.

> I could try tracking whether IPv4/6 work, but then that is going to
> cause problems if the host is actually down. Maybe I'll just make
> bridge connections blocking, but in another thread, in the great big
> bridge overhaul of the future.

I don't understand the code enough to have an opinion, but I think the
functional requirement is that whatever the 'try to connect to address
X' procedure is, when that fails, then the next connection attempt
should choose the next address from the getaddrinfo list.

A workaround for now might be to choose a random member of the
getaddrinfo set instead of picking the first.   The real problem is a
scenario like:

  target has one AAAA and one A record.

  normally both work

  Now, IPv6 packets to the AAAA value are dropped and time out, but IPv4
  works.  Or the other way around.

  the OS always puts v6 first.

leading to trying v6 for hours until it works again with no connectivity
in the middle.  I am 90% sure that's what I've seen.

I'll try to read the code and see if a low-impact fix is feasible, and
at least file a high-quality bug report if I can rig up a test harness.

Greg

Attachment: signature.asc
Description: PGP signature


Back to the top