DnsClient.NET icon indicating copy to clipboard operation
DnsClient.NET copied to clipboard

Timeout when querying TXT records

Open Katulus opened this issue 3 years ago • 1 comments

Hello, I hit a strange issue when certain TXT queries are timing out unless I enforce TCP.

Code that fails: Following code times out with: DnsClient.DnsResponseException : Query 38620 => amazon.com IN TXT on 8.8.8.8:53 timed out or is a transient error. ---- System.OperationCanceledException : The operation was canceled.

var client = new LookupClient();
var question = new DnsQuestion("amazon.com", QueryType.TXT, QueryClass.IN);
var options = new DnsQueryAndServerOptions(IPAddress.Parse("8.8.8.8"))
{
};
// This call times out
var result = await client.QueryAsync(question, options);

Code that works: Following code works fine and returns proper result.

var client = new LookupClient();
var question = new DnsQuestion("amazon.com", QueryType.TXT, QueryClass.IN);
var options = new DnsQueryAndServerOptions(IPAddress.Parse("8.8.8.8"))
{
    UseTcpOnly = true
};
// This call succeeds in under a second
var result = await client.QueryAsync(question, options);

I tried with my local provider's DNS server as well as with Google 8.8.8.8 (in samples above) and both behave the same. If I try to query some record with less TXT records such as outlook.com it works even without UseTcpOnly = true. amazon.com has 22 TXT records.

I would like to avoid UseTcpOnly = true because I'll be running lots of small DNS queries that will in 99% work perfectly fine over UDP.

Any ideas what could be the issue here?

Katulus avatar Oct 13 '23 13:10 Katulus

Sorry for the late reply, but I guess you figured it out in the meantime that this is most likely a network related problem with your own setup and has nothing todo with the client library or the DNS server. Hint: Local VPN services often block DNS traffic, but could be anything..

MichaConrad avatar Jan 02 '24 10:01 MichaConrad