[CSHARP-3015] System.IndexOutOfRangeException: Reading IPv4 address, expected 4 bytes. Created: 14/Mar/20  Updated: 18/Mar/20  Resolved: 18/Mar/20

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

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

Windows 10. Visual Studio Community Version 2019



 Description   

Hi, I am able to connect from Compass and perform all CRUD operations on collection. However, I am getting below exception when doing insert using .Net driver. 

I have also tested by "Allow from Anywhere" option in IP Whitelisting but that doesn't work either.

 

Here is my connection string

"mongodb+srv://mongodb-user:password@my-production-i5mve.mongodb.net/?retryWrites=true&w=majority&ssl=true&connect=replicaSet"

 

I also tried by adding/removing options in connection string. e.g. removing connect=replicaSet etc. But nothing worked.

 

A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector

{ AllowedLatencyRange = 00:00:00.0150000 }

}. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [], DnsMonitorException : "DnsClient.DnsResponseException: Unhandled exception
---> System.IndexOutOfRangeException: Reading IPv4 address, expected 4 bytes.
at DnsClient.DnsDatagramReader.ReadIPAddress()
at DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData)
at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout)
at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit)
— End of inner exception stack trace —
at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit)
at DnsClient.LookupClient.QueryInternal(IReadOnlyCollection`1 servers, DnsQuestion question, Boolean useCache)
at DnsClient.LookupClient.Query(String query, QueryType queryType, QueryClass queryClass)
at MongoDB.Driver.Core.Misc.DnsClientWrapper.ResolveSrvRecords(String service, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Clusters.DnsMonitor.Monitor()" }.



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

prasoon@metalbrain.in, we will update the version of DnsClient in the next release.

kletterer@web.de, thank you for your participation.

Comment by Prasoon Gupta [ 18/Mar/20 ]

Hi Michael, Upgrading DnsClient to v1.3.0 worked. Thanks for the help

Comment by Prasoon Gupta [ 17/Mar/20 ]

Hi Michael, This issue only occurs while I use my internet connection at home. I could not try your suggestion so far but I will give you an update today because I am working from home due to Covid19. 

Comment by Michael Conrad [ 15/Mar/20 ]

Did you see my comment on your 2nd issue reporting the same problem?

Here again:

This might also be related to this issue https://github.com/MichaCo/DnsClient.NET/issues/51

and #CSHARP-2968

Would be great if you could try upgrading DnsClient to v1.3.0 (beta) and try with that?

Did you try that?

 

Regarding your last comment, that's probably not helping, you most likely have 2 different DNS servers sending different responses and one of them sends somehting DnsClient cannot handle. Again, I'm pretty sure that'll be fixed in 1.3.0 of DnsClient, if you could try that out that would help me a lot.

Thanks!

 

 

Comment by Prasoon Gupta [ 15/Mar/20 ]

I am not sure the exact problem but it is definitely related to what network I use. I tested by connection it to my mobile's hot-spot and it worked. But when I again switched to broadband connection and it fails. Hope it helps someone.

Comment by Prasoon Gupta [ 14/Mar/20 ]

It was working fine till yesterday and I have not changed anything but suddenly it stopped working.

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