Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InvalidOperationException: Record reader index out of sync

I have asp.net core application which uses mongodb as backend.

Recently I have started getting this error without any changes in database or code.

Here is complete error I am getting when I browse my API

An error occurred while starting the application.
InvalidOperationException: Record reader index out of sync.
DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)

DnsResponseException: Unhandled exception
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)

InvalidOperationException: Record reader index out of sync.
DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment<byte> responseData)
DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout)
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)

Show raw exception details
DnsResponseException: Unhandled exception
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)
DnsClient.LookupClient.Query(DnsQuestion question)
MongoDB.Driver.Core.Configuration.ConnectionString.Resolve()
MongoDB.Driver.MongoUrl.Resolve()
MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
MongoDbGenericRepository.MongoDbContext..ctor(string connectionString, string databaseName)
Microsoft.Extensions.DependencyInjection.MongoDbIdentityBuilderExtensions.AddMongoDbStores<TUser, TRole, TKey>(IdentityBuilder builder, string connectionString, string databaseName)
AspNetCore.Identity.MongoDbCore.Extensions.ServiceCollectionExtension.ConfigureMongoDbIdentity<TUser, TRole, TKey>(IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration, IMongoDbContext mongoDbContext)
BrightSteps.Web.Api.Extensions.Utility.ConfigureMongoIdentity(IServiceCollection services, MongoDbSettings settings) in Utility.cs
BrightSteps.Web.Api.Startup.ConfigureServices(IServiceCollection services) in Startup.cs
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Show raw exception details
like image 246
Krunal Parmar Avatar asked Feb 27 '20 07:02

Krunal Parmar


1 Answers

It turns out, that issue was with connection string and my driver version.

C# MongoDB driver is depend on DNSClient.Net Package, which is uses to do DNS lookup for connection string.

Since I was using older version of driver it does not support SVR connection string of mongo db and I have to use Non SVR Connection string in mongodb.

like image 154
Krunal Parmar Avatar answered Nov 17 '22 13:11

Krunal Parmar