[CSHARP-2852] DnsClient.DnsResponseException: Unhandled exception when using mongodb+srv:// Created: 12/Nov/19  Updated: 03/Apr/20  Resolved: 26/Mar/20

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.9.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Brecht Vanhaesebrouck Assignee: Dmitry Lukyanov (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

docker on ubuntu linux in azure.


Issue Links:
Duplicate
duplicates CSHARP-2968 Exception occurs when using mongodb+s... Closed
Case:

 Description   

I cannot connect to mongoDB atlas using an srv record. I am using a peered connection in azure. The host machine itself can resolve the SRV record. I tested it using this command on my ubuntu sever.

host -t srv _mongodb._tcp.xxxxxxxxx.azure.mongodb.net

An example of my connnection string: mongodb+srv://<username>:<password>@xxxxxxxxx.azure.mongodb.net/test. 

I am using .net core 3. The base container of my docker container is mcr.microsoft.com/dotnet/core/aspnet:3.0-alpine3.9 .

Here's the exception i get:

 

Unhandled exception. DnsClient.DnsResponseException: Unhandled exception
2019-11-12T09:46:08.645385629Z ---> System.InvalidOperationException: Record reader index out of sync.
2019-11-12T09:46:08.645410429Z at DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
2019-11-12T09:46:08.645418229Z at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData)
2019-11-12T09:46:08.645438129Z at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout)
2019-11-12T09:46:08.645443729Z at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit)
2019-11-12T09:46:08.645449029Z --- End of inner exception stack trace ---
2019-11-12T09:46:08.645453629Z at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit)
2019-11-12T09:46:08.645458929Z at DnsClient.LookupClient.QueryInternal(IReadOnlyCollection`1 servers, DnsQuestion question, Boolean useCache)
2019-11-12T09:46:08.645463929Z at DnsClient.LookupClient.Query(String query, QueryType queryType, QueryClass queryClass)
2019-11-12T09:46:08.645468929Z at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve(Boolean resolveHosts)
2019-11-12T09:46:08.645473530Z at MongoDB.Driver.MongoUrl.Resolve(Boolean resolveHosts)
2019-11-12T09:46:08.645478430Z at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)

 

When using an oldschool connection string (not depending on an srv record) I can connect to my cluster.



 Comments   
Comment by Dmitry Lukyanov (Inactive) [ 26/Mar/20 ]

The scope of this ticket will be implemented in CSHARP-2968

Comment by Jeffrey Yemin [ 22/Nov/19 ]

support@sea-invest.com

We've talked with the Atlas team and have learned that there have been a few examples of customers on Azure having DNS problems with SRV records. So far we have seen these issues for customers on Azure Windows Webapps and Azure AppServices, but this may impact more Azure services. Can you confirm whether you have an open support inquiry with Azure around this? If not, we suggest you open one up, and please share with us the Azure service context you're using so that we can mention this to our own Azure support contacts.

Generated at Wed Feb 07 21:43:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.