Skip to content
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

Cant read that many bytes error #22

Closed
chr4ss1 opened this issue May 7, 2018 · 3 comments
Closed

Cant read that many bytes error #22

chr4ss1 opened this issue May 7, 2018 · 3 comments

Comments

@chr4ss1
Copy link

chr4ss1 commented May 7, 2018

I am trying to query the hotmail.com servers like so:

var result = await this.lookupClient.QueryAsync("hotmail.com", QueryType.ANY).ConfigureAwait(false);
                var records = result.Answers.Where(record => record.RecordType == DnsClient.Protocol.ResourceRecordType.A ||
                                                             record.RecordType == DnsClient.Protocol.ResourceRecordType.AAAA ||
                                                             record.RecordType == DnsClient.Protocol.ResourceRecordType.MX);

however it blows up with the following response:

DnsClient.DnsResponseException: Unhandled exception ---> System.IndexOutOfRangeException: Cannot read that many bytes: '68'.
   at DnsClient.DnsDatagramReader.ReadBytes(Int32 length)
   at DnsClient.DnsRecordFactory.ResolveTXTRecord(ResourceRecordInfo info)
   at DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
   at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData)
   at DnsClient.DnsUdpMessageHandler.<QueryAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.TaskExtensions.<WithCancellation>d__0`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DnsClient.LookupClient.<ResolveQueryAsync>d__63.MoveNext()
   --- End of inner exception stack trace ---
   at DnsClient.LookupClient.<ResolveQueryAsync>d__63.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DnsClient.LookupClient.<QueryAsync>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()

I tried gmail.com instead, and it worked without problems. Any ideas?

@MichaCo
Copy link
Owner

MichaCo commented May 7, 2018

That usually is caused by an invalid/incomplete message. The parser tries to read a message of a certain length but there is not enough data to read that from.

What DNS server are you using?

@chr4ss1
Copy link
Author

chr4ss1 commented May 7, 2018

I'll do some more investigation later, however I don't think it's related to library itself, so I might close it. It is quite weird because I don't have any custom setup and my browsers show hotmail.com fine.

Chriss-MBP:dotnet chriseelmaa$ host -a hotmail.com
Trying "hotmail.com"
Trying "hotmail.com"
;; Connection to 192.168.1.1#53(192.168.1.1) for hotmail.com failed: connection refused.
Chriss-MBP:dotnet chriseelmaa$ host -a google.com
Trying "google.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3608
;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	ANY

;; ANSWER SECTION:
google.com.		209	IN	A	216.58.213.110
google.com.		600	IN	MX	30 alt2.aspmx.l.google.com.
google.com.		600	IN	MX	10 aspmx.l.google.com.
google.com.		600	IN	MX	40 alt3.aspmx.l.google.com.
google.com.		600	IN	MX	50 alt4.aspmx.l.google.com.
google.com.		600	IN	MX	20 alt1.aspmx.l.google.com.
google.com.		345600	IN	NS	ns4.google.com.
google.com.		345600	IN	NS	ns3.google.com.
google.com.		345600	IN	NS	ns2.google.com.
google.com.		345600	IN	NS	ns1.google.com.

Received 503 bytes from 192.168.1.1#53 in 25 ms
Chriss-MBP:dotnet chriseelmaa$ nslookup hotmail.com
Server:		192.168.1.1
Address:	192.168.1.1#53

Non-authoritative answer:
Name:	hotmail.com
Address: 204.79.197.212

@MichaCo
Copy link
Owner

MichaCo commented May 7, 2018

If I run it with the library, e.g. on dnsclient.michaco.net, it totally works.

Those things depend on the response of the DNS server you use of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants