我在 Atlas 上有一個(gè) MongoDB,我正在從 ASP.NET Core MVC 應(yīng)用程序中查詢它。在我的 Context 類中,我從構(gòu)造函數(shù)初始化 MongoClient,如下所示:var client = new MongoClient(settings.Value.ConnectionString);if (client != null){ _database = client.GetDatabase(settings.Value.DatabaseName);}存儲(chǔ)庫類作為瞬態(tài)服務(wù)注入到我的控制器中services.AddTransient<IMovieRepository, MovieRepository>();如果我嘗試從該數(shù)據(jù)庫的集合中獲取某些內(nèi)容,則第一次嘗試時(shí)一切正常。如果我刷新頁面,它會(huì)嘗試再次創(chuàng)建 MongoClient 并失敗向我拋出DnsResponseException. 之后我必須等待一分鐘左右,它才能再次工作。Robo3T 讓我可以執(zhí)行任意數(shù)量的連續(xù)查詢,因此我猜問題可能只出現(xiàn)在 C# MongoClient 上......這是我得到的完整異常:;; Error: Cannot read byte 269, out of range.System.IndexOutOfRangeException: Cannot read byte 269, out of range. at DnsClient.DnsDatagramReader.ReadByte() at DnsClient.DnsDatagramReader.ReadLabels() at DnsClient.DnsDatagramReader.ReadQuestionQueryString() at DnsClient.DnsRecordFactory.ReadRecordInfo() 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);; Error: Cannot read byte 269, out of range.System.IndexOutOfRangeException: Cannot read byte 269, out of range. at DnsClient.DnsDatagramReader.ReadByte() at DnsClient.DnsDatagramReader.ReadLabels() at DnsClient.DnsDatagramReader.ReadQuestionQueryString() at DnsClient.DnsRecordFactory.ReadRecordInfo() 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)有誰知道我為什么會(huì)遇到此異常以及如何解決它?
1 回答

Cats萌萌
TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超9個(gè)贊
我已經(jīng)遇到這個(gè)錯(cuò)誤 3 天了,已經(jīng)絕望地將我的 DNS 設(shè)置更改為:
- 1 回答
- 0 關(guān)注
- 204 瀏覽
添加回答
舉報(bào)
0/150
提交
取消