首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法调用Azure搜索特定的asp.net .netframework 4.7.1项目(RequestFailedException)

无法调用Azure搜索特定的asp.net .netframework 4.7.1项目(RequestFailedException)
EN

Stack Overflow用户
提问于 2022-01-27 08:53:06
回答 1查看 143关注 0票数 0

我有一个asp.net 4.7.1项目(在过去6-7年间升级到4.7.1 ),我无法从该项目中连接/调用Azure Searchc中的任何方法。我得到了一个RequestFailedException (结束时的完整日志)

不幸的是,我不能复制在新的控制台应用程序,新的Asp.net 4.7.1项目!

我在同一台Visual 2022的同一台机器上运行所有类型的项目。

我用相同的代码和相同版本的Nuget (11.3.0)调用搜索服务。(我尝试过早期版本,也尝试过11.1.1,但也有相同的错误)。我使用的是相同的服务/索引和键(目前只是一个免费服务,但如果遇到其他服务,则没有任何不同)。

我的遗嘱是:

代码语言:javascript
复制
var searchIndexClient = new SearchIndexClient(new 
Uri($"https://sfsearchtest.search.windows.net"),
new AzureKeyCredential("70C978F2751C051E0BF156B0....."),
options);
noIndexes = searchIndexClient.GetIndexes().Count();

(我把钥匙弄糊涂了)

如果我尝试callanothr方法,那么"GetIndexes“并不重要。同样的错误。注意,我已经设置了MaxRetries = 0;但是更多的重试会产生相同的错误,所以我已经拒绝了0重试。

在经历了几天的挫折/测试之后,帮助真的得到了赏识。请不要要求我将项目更新为.Netcore ;-)

我对“我的项目”的ddl和新创建的4.7.1项目进行了比较,它们是完全相同的文件。

下面是一个错误日志(来自AzureEventSourceListener.CreateConsoleLogger和

代码语言:javascript
复制
AzureEventSourceListener.CreateTraceLogger).

Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] GET https://sfsearchtest.search.windows.net/indexes?$select=*&api-version=2020-06-30
Accept:application/json; odata.metadata=minimal
api-key:REDACTED
x-ms-client-request-id:916938f7-cc37-483b-a134-33ca2c69d22b
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Search.Documents/11.3.0 (.NET Framework 4.8.4420.0; Microsoft Windows 10.0.19044 )
client assembly: Azure.Search.Documents
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] GET https://sfsearchtest.search.windows.net/indexes?$select=*&api-version=2020-06-30
Accept:application/json; odata.metadata=minimal
api-key: REDACTED
x-ms-client-request-id:916938f7-cc37-483b-a134-33ca2c69d22b
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Search.Documents/11.3.0 (.NET Framework 4.8.4420.0; Microsoft Windows 10.0.19044 )
client assembly: Azure.Search.Documents
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'Azure.RequestFailedException' in Azure.Core.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] exception Azure.RequestFailedException: The underlying connection was closed: An unexpected error occurred on a send.
   at Azure.Core.Pipeline.HttpWebRequestTransport.<ProcessInternal>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Core.Pipeline.HttpWebRequestTransport.Process(HttpMessage message)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.RequestActivityPolicy.ProcessNextAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Core.Pipeline.RequestActivityPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Core.Pipeline.ResponseBodyPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] exception Azure.RequestFailedException: The underlying connection was closed: An unexpected error occurred on a send.
   at Azure.Core.Pipeline.HttpWebRequestTransport.<ProcessInternal>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Core.Pipeline.HttpWebRequestTransport.Process(HttpMessage message)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.RequestActivityPolicy.ProcessNextAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Core.Pipeline.RequestActivityPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Core.Pipeline.ResponseBodyPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
Exception thrown: 'Azure.RequestFailedException' in Azure.Core.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in Azure.Search.Documents.dll
EN

回答 1

Stack Overflow用户

发布于 2022-01-27 16:58:42

好的。我设法解决了。简短的答覆是:

代码语言:javascript
复制
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;

Tls以前也曾引起过问题。不知道为什么我的旧项目会导致这个问题(找不到任何关于tls的东西)。幸运的是,这起了作用:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70875676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档