2016-11-07 38 views
5

我正在使用Azure Search .Net SDK。任务被取消 - 这是什么意思?

我打电话同步(不是异步)函数是这样的:

var searchResults = searchIndexClient.Documents.Search<T>(searchText, searchParameters); 

它通常工作。我没有使用任何异步函数,但不知何故错误我刚刚看起来像一个异步错误:

System.Threading.Tasks.TaskCanceledException: A task was canceled. 

CancellationToken: IsCanceleationRequested=false 

Task: Id = 556, Status = Canceled, Method = "{null}", Result = "{Not yet computed}" 

StackTrace: 

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__15 3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__15 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.Search[T](IDocumentsOperations operations, String searchText, SearchParameters searchParameters, SearchRequestOptions searchRequestOptions) at MyApp.AzureSearch.AzureSearchService.PerformSearch[T](String searchText, SearchParameters searchParameters) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 359 at MyApp.AzureSearch.AzureSearchService.Search[T](String searchText, List 1 searchFields, SearchMode searchMode, List 1 select, Nullable 1 skip, Nullable 1 top, String filter, Boolean includeTotalResultCount, List 1 orderBy) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 262 at MyApp.AzureSearch.AzureSearchService.SearchEmails(Guid userId, String origin, String searchText, Nullable 1 skip, Nullable 1 top, Boolean includeTotalResultCount, Boolean includeHtmlBody, Boolean orderByProcessedAscending, String interactionStatus) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 167 at MyApp.Domain.MyAppMessages.Command.MyAppMessagesAllNoticedUpdater.Handle(VisitorSession userSession, NoticeAllMyAppMessages processCommand) in c:\Projects\MyAppServer\src\MyApp.Domain\MyAppMessages\Command\MyAppMessagesAllNoticedUpdater.cs:line 30

回答

3

最有可能的,搜索完成之前,客户端超时。您提交特别复杂的查询时是否看到此错误?如果需要,您可以使用search traffic analytics查看服务中的搜索性能。

您看到“异步”异常的原因是API的同步版本只是异步基元的封装。

+0

谢谢,我想它只是包装一个异步功能。它根本不是一个复杂的查询,查询中的数据也很少。我没想到.net SDK会抛出错误,除非在查询中配置错误。是否有我可以处理的.net sdk可能引发的所有可能的错误列表? – richard

+0

可以抛出的主要异常是:'CloudException','IndexBatchException'(仅用于索引),'ValidationException',当然还有'OperationCanceledException'(或其子类'TaskCanceledException'你正在处理这里)。但是由于C#不是检查的异常语言,您可能也会看到其他异常(如ArgumentException)。 –