Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3015

System.IndexOutOfRangeException: Reading IPv4 address, expected 4 bytes.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.2
    • Component/s: Connectivity
    • Labels:
      None
    • Environment:
      Windows 10. Visual Studio Community Version 2019

      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()" }.

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            prasoon@metalbrain.in Prasoon Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: