DnsServer icon indicating copy to clipboard operation
DnsServer copied to clipboard

DNS-over-QUIC: the retry only covers two errors, and Quad9 returns neither

Open Ellingson opened this issue 2 months ago • 10 comments

I forward to Quad9 over QUIC and got intermittent SERVFAILs for months. I switched the same server to DoT, to the same two Quad9 addresses, and they stopped completely. I think the difference is one line in the QUIC client's retry check.

My setup

  • Technitium DNS Server 15.4 on .NET 10.0.11, Linux
  • Forwarders: dns.quad9.net:853 (9.9.9.9) and dns.quad9.net:853 (149.112.112.112)
  • forwarderProtocol: Quic, forwarderConcurrency: 2, forwarderRetries: 3

What I measured

Over seven days on QUIC, my server logged 2,306 failed forwarder queries. Every one was a QuicException, and there were only two messages between them: Stream aborted by peer (5). (1,470) and Operation aborted. (836).

I then switched only forwarderProtocol to Tls — same addresses, same box, nothing else changed. In the 7.5 hours since, there have been zero. At the rate I had been seeing, that window should have produced somewhere between 50 and 100.

What I think is happening

In TechnitiumLibrary.Net/Dns/ClientConnection/QuicClientConnection.cs (QueryAsync → QuicQueryAsync), a failed query throws the connection away and retries — but only for two specific errors:

if (((ex.QuicError == QuicError.ConnectionIdle) || (ex.QuicError == QuicError.ConnectionAborted)) && (retry == 1))
{
    retry = 0;
    continue;
}
throw;

Neither of my two errors is on that list, so the retry never ran. All 2,306 failures gave up on the first try. It does recover by itself — the next query builds a fresh connection and works — so this is one failed lookup each time, not a stuck connection pool.

My guess is that Quad9 closes connections that have gone quiet, and closes them in a way that shows up as a stream abort rather than an idle timeout. I can't see Quad9's side, so that part is a guess. Any server that behaves the same way would hit this.

I read the open library PR and I don't think it covers this

https://github.com/TechnitiumSoftware/TechnitiumLibrary/pull/62 — "Fix DNS-over-QUIC stream lifetime under cancellation". It changes how connections and streams are created and cleaned up, but leaves the retry check unchanged, so both of my errors still fail on the first try with it applied.

The change I'd suggest

The connection has already been thrown away by the time this check runs, so a retry gets a fresh one. Retrying once on any error would cover it:

if (retry == 1)
{
    retry = 0;
    continue;
}
throw;

The TCP client, which the TLS client inherits from, already retries on IOException generally rather than on a list of specific errors.

Two things I could not work out, in case they matter

  1. I have forwarderRetries set to 3, and it did not hide this. I don't know why those retries didn't cover it, and I couldn't work it out from the source.
  2. I don't know how long each connection had been idle before it failed. My logs record the error but not the gap before it.

I haven't tested the patch — I moved to DoT instead, so the fix is a suggestion rather than something I've proven. Happy to send raw log lines if they'd help.

Ellingson avatar Sep 07 '26 14:09 Ellingson

Corrected PR62 link. Oops!

Ellingson avatar Sep 07 '26 15:09 Ellingson

Thanks for the feedback. Will check this issue in detail.

ShreyasZare avatar Sep 08 '26 06:09 ShreyasZare

Technitium DNS Server v15.5 is now available that fixes this issue. Do update and let me know your feedback.

ShreyasZare avatar Sep 19 '26 15:09 ShreyasZare

This problem only started with me with update 15.5! DoQ doesn't work anymore (with Quad9), but DoH and DoT do. This wasn't a problem with the previous version.

sammyjo468 avatar Sep 22 '26 11:09 sammyjo468

@sammyjo468 Thanks for the feedback. Please share error logs you see from the Logs > View Logs section.

ShreyasZare avatar Sep 22 '26 11:09 ShreyasZare

Follow-up from the original report, with a day of numbers on 15.5 — and a data point for the Quad9 report above.

Setup (same box as my report): Raspberry Pi 5, Debian, forwarding only, to Quad9 dns.quad9.net:853 (9.9.9.9 and 149.112.112.112). forwarderConcurrency: 2, forwarderRetries: 3, forwarderTimeout: 5000. I updated to 15.5 on 2026-09-22 and switched forwarderProtocol back from Tls to Quic the same day. Nothing else changed.

DoQ to Quad9 works on 15.5 here. Right after the switch, 300 uncached lookups in a row all answered over DoQ (median 29 ms).

The failures from my report are almost gone. Quad9 forwarder failures in the server log, same box, same counting script:

day (UTC) version protocol Quad9 failures "Stream aborted by peer (5)" "Operation aborted."
2026-09-06 15.4 DoQ 137 94 43
2026-09-21 15.4 DoT 117 (mostly EndOfStreamException) 0 0
2026-09-24 15.5 DoQ 5 1 1

On 15.5 those 5 were 2 QuicException, 1 timeout and 2 DnsServerException.

Since 15.5 only logs a failure after every retry has failed, it looks like the retry change is absorbing nearly all of them: 94 → 1 and 43 → 1. I can't count the retries that worked, because they leave nothing in the log.

So I can't reproduce "DoQ doesn't work anymore with Quad9" on 15.5. Happy to run anything else that would help. Thanks for the fix.

Ellingson avatar Sep 25 '26 09:09 Ellingson

@Ellingson thanks for the detailed feedback. Good to know that the issue is resolved now.

ShreyasZare avatar Sep 25 '26 10:09 ShreyasZare

Not with me. Relevant log is

new 1.txt

DNS request forwarded to 9.9.9.9:853 and 149.112.112.112:853, DNS-over-QUIC. Please note that I didn't have any problems with it in the previous version. Going back and forth between DoQ and DoT doesn't seem to matter. All requests are denied over DoQ.

sammyjo468 avatar Sep 25 '26 12:09 sammyjo468

@sammyjo468 This seems to be a bug with dotnet as described in this issue.

You can fix this by using dns.quad9.net (9.9.9.9:853) as the forwarder instead of just using the IP address.

ShreyasZare avatar Sep 25 '26 12:09 ShreyasZare

You can fix this by using dns.quad9.net (9.9.9.9:853) as the forwarder instead of just using the IP address.

I can confirm that this work around works fine. Not a def solution, but for now it's solved. Thanks!

sammyjo468 avatar Sep 25 '26 17:09 sammyjo468