-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DnsResponseException: Trying to read truncated (invalid) response #52
Comments
Looking at the actual DNS entry, I see there are 15 values in that TXT record (not zero) - so maybe this is an Azure DNS bug? (the TTL is 1 minute if that makes any difference) |
OK so it looks like Azure is not at fault, executing the query directly works: |
I actually cannot reproduce the error, I'm running
For >10 minutes minutes now and no error... The error you got means that the response wasn't complete, meaning there are bytes missing and the parser bailed out. Which is usually the right thing to do... Regarding those kind of errors, I was hesitant to make those kind of errors transient and have the client retry the request. But I think it's the only thing which makes sense; to run the same query again and hope the network doesn't screw it up again ^^ In the meantime, I guess to make your app more stable, do a retry yourself with a bit delay between each retry in case there is a throttle? |
No point in retrying, it is very consistent. The reason your requests have been successful is that I've since modified that record and reduced the value count to unblock myself. My setup is very mainstream (Windows 10, .NET 4.7.2) and reproducing the issue is easy - apparently you just need to query some I get what you're saying about the incomplete message but:
|
@ohadschn tldr: I still cannot reproduce it. I ran a couple long running tests against 40.90.4.1 with different frameworks and using TCP instead of UDP and other settings. Never got any error... When I test the library locally, I have a server with domains with way more records, too. So, I don't really know anymore what else to try to reproduce what you experience ~~ |
Just to clarify, you used the new TXT record I created Also, how about printing out the parts of the message you were able to decode and the raw bytes for debugging? |
Yea, I used Regarding printing the error details. That sounds like a great idea but isn't that trivial I think. Have to take a look. |
Hi @ohadschn, Could you maybe give the latest beta version from myget and maybe also attach to the log output and let me know what how that works? ;) Changes are currently in this PR #58 |
also /closing this one as duplicate of #51 |
Thanks! Retries didn't help as expected (like I said this is consistent for me) but the error is a bit more detailed now:
|
@ohadschn The bytes are as a property |
Cool, here are the bytes for your inspection:
IMHO this printout should be added to the exception's |
Well, obviously this is incomplete data, the header states there are 18 answers. The data contains 8 of those answers. Reading the 9th answer then fails. The suspicious thing here is that the array is exactly 512 bytes, which is exactly the magic number which defines the limit of a DNS UDP payload in the classic DNS spec (before EDNS0). There are still a lot of proxies and routers and firewalls artificially truncating the payload. Per spec the expectation here is that a server sets a header flag indicating the result is truncated. In your case though, that flag is not set which is actually not a valid response. My assumption is that you are using some DNS proxy or router or firewall which alters the UDP payload between your machine and the server in Azure. Something just truncates the response from the server. Because, I cannot reproduce it with my network.
If the "middlebox" in your network would just remove the OPT record, the server would probably return a valid truncated result, but this doesn't seem to be the case. You could try to set the LookupClient's settings to use TCP only, which would not even try the UDP path. At least to see if it works. I will re-open this issue as it turns out it is in fact something different. |
Thank you for looking into this!
Right again, my router (PepWave Surf SOHO Mk III) is indeed configured to "Forward Outgoing DNS Requests to Local DNS Proxy" (this is a security measure). When I turn it off, the issue disappears. Do you think this is the issue? https://forum.peplink.com/t/edns0-support-in-peplink/130
Apparently this is exactly what
|
Regarding your router, not really sure there are a couple of issues, e.g. https://forum.peplink.com/t/peplink-dns-dnssec-edns/19085 And seems they did provide firmware updates to comply with the recommendations from dnsflagday in 2019 |
I have the most up to date firmware, released about 3 months ago, and in any case newer than the DNS flag day firmware. So it looks like a bug. I want to report it, so let me know if I got it right:
|
It's the TC flag on the header https://tools.ietf.org/html/rfc1035#section-4.1.1 |
I guess on your end you could implement the auto retry (as Also, I believe the |
Thanks! I can confirm it works as expected:
Is there some verbosity flag you want me to switch on to verify in the logs things are working as you expect them to, or is the above result proof enough? |
Cool! That's great, thanks. If you run your tests as a Console app you can use this
You can also set There should be some message about the TCP fallback and the bad truncation. |
Looks great!
One thing that looks strange is that the second resolution attempt still says UDP?
|
Yeah, the logging just prints the NameServer.ToString() which contains the server's known buffer size. |
Sure, but perhaps it would be nice to mention somewhere in the query log itself the protocol it's actually using, something like: |
* changed how opt records are created and used. Added configuration to disable EDNS and to set the requested buffer size and DnsSec * Changes the behavior in case of bad responses which were truncated by some middleman proxy or router - fixes #52 * Changing default unknown record handling to preserve the original data so that users can work with those records. * Reworking error handling see #60 * Adding new setting ContinueOnEmptyResponse #64
The changes are now released on NuGet https://www.nuget.org/packages/DnsClient/1.3.0 |
I'm trying to query a nameserver (
40.90.4.1:53 (Udp: 512)
) for aTXT
record and getting the following:It happens after a few retries, so I think it might be rate limiting / throttling. In this issue #22 you mentioned that it's a sign of an invalid/incomplete message, so it would be great if you could print the raw response in such cases. This way we have more debugging information to work with other than "bad message".
The text was updated successfully, but these errors were encountered: