-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.10.1
-
Component/s: Connectivity, Error Handling
-
None
-
Environment:AKS (Linux) - Server version v1.14.8
-
(copied to CRM)
Our C# applications have been quite happily connecting to various MongoDB Atlas clusters using the SRV connection string for roughly a year now. Since the start of this month, (and about 2 weeks after we upgraded to .NET Core 3.1), we started getting an error with the MongoDB connection 'Record reader index out of sync.'
Looking into it a bit further, it appears that the problem manifests in in the DnsClient package (v1.2.0). It seems to work just fine on my windows machine, on my linux boxes, but not within my AKS environment.
Suspiciously, Microsoft have recently started rolling out a change to CoreDNS ( https://github.com/Azure/AKS/blob/master/CHANGELOG.md )
Spoke to Mary Gorman at support and tested this out on an M10 instance, same results and have the logs attached (though I suspect the problem is within AKS and nothing to do with the database itself).
This can be recreated using .NET Core 3.1 and a reference to the DnsClient package and the following code running in a .NET Core 3.1 Alpine container within AKS:
````
class Program
{
static void Main(string[] args)
{
try
");
foreach (DnsResourceRecord dnsResourceRecord in result.AllRecords)
Console.WriteLine(dnsResourceRecord.ToString());
}
catch (Exception e)
Console.ReadLine();
}
}
````
Replace the mongoDB host for a valid cluster if the one supplied is no longer there - this happens on the free tier and M10 lookups.
You will end up with an error that looks like this:
````
DnsClient.DnsResponseException: Unhandled exception
---> System.InvalidOperationException: Record reader index out of sync.
at DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\DnsRecordFactory.cs:line 181
at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\DnsMessageHandler.cs:line 114
at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\DnsUdpMessageHandler.cs:line 66
at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit continueAudit) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\LookupClient.cs:line 724
— End of inner exception stack trace —
at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit continueAudit) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\LookupClient.cs:line 835
at DnsClient.LookupClient.QueryInternal(DnsQuestion question, DnsQuerySettings settings, IReadOnlyCollection`1 useServers) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\LookupClient.cs:line 650
at DnsClient.LookupClient.Query(String query, QueryType queryType, QueryClass queryClass, DnsQueryOptions queryOptions) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Src\LookupClient.cs:line 401
at DnsClientTest.Program.Main(String[] args) in C:\Users\jason\Source\Repos\DnsClientTest\DnsClientTest\Program.cs:line 15
````
Please note, that this error only occurs within AKS! It does not seem to manifest on a Windows 10 machine, or on a Linux box outside of AKS.
This has been cross reported here: https://github.com/MichaCo/DnsClient.NET/issues/51
I can obviously get round this issue by not using seedless connection strings (non SRV connection strings), but SRV connection strings are far preferable from a maintainability point of view.
- is duplicated by
-
CSHARP-2852 DnsClient.DnsResponseException: Unhandled exception when using mongodb+srv://
- Closed
- related to
-
CSHARP-2977 Unable to connect to name server
- Closed
-
CSHARP-2518 Dns resolver only uses first DNS server.
- Closed
- links to
- mentioned in
-
Page Loading...