gpt4 book ai didi

c# - MS Graph api : Timeout when converting docx to pdf

转载 作者:行者123 更新时间:2023-12-03 13:41:15 28 4
gpt4 key购买 nike

我在Microsoft.Graph.ServiceException中得到带有Code: timeout Message: The request timed out.Microsoft.Graph.Core,并具有以下堆栈跟踪:

   at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendStreamRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at MyCode.cs
服务器返回以下 header :
"X-CorrelationId": "605c9349-69e2-4569-acb5-ff9fec9aa887.5e6c48a9-6492-497a-857f-a373bff98f37"
"X-OneDriveMeTA-Version": "1.0.7615.29479"
"X-ErrorCode": "General_Timeout"
"X-ErrorType": "Unexpected"
"X-ErrorSource": "Service"
"X-AspNet-Version": "4.0.30319"
"X-MSEdge-Ref": "Ref A: 71954E8D2D9F46ACAE2CA0953006DE5D Ref B: VIEEDGE1811 Ref C: 2020-11-30T08:56:32Z"
服务器响应:
"Date": "Mon, 30 Nov 2020 08:57:24 GMT"
"StatusCode": "InternalServerError"
"RawResponseBody": "{\"error\":{\r\n \"code\": \"generalException\",\r\n \"message\": \"The operation has timed out.\",\r\n \"innererror\": {\r\n \"code\": \"General_Timeout\"\r\n }\r\n}}"
C#代码:
var queryOptions = new List<QueryOption> { new QueryOption('format', 'pdf') };
var pdf = await graphClient.Drives[folderId]
.Items[docxId]
.Content
.Request(queryOptions)
.GetAsync();
通常,此代码有效,但隔天就会超时。如果只超时一次,那是可以的,但有些用户会连续经历多次超时,因此即使重试也无济于事。
有没有办法获取有关此问题的更多信息?我可以在某处访问日志/更详细的错误消息吗?

最佳答案

  • 如果大量数据导致超时异常,则需要在分页中使用。看更多
    在:https://docs.microsoft.com/en-us/graph/paging2
  • 您可以通过设置超时来延长超时时间:
    graphClient.HttpProvider.OverallTimeout = TimeSpan.FromHours(1);

  • 上面的两个选项都可以解决您的问题,但是即使不这样做,它们对于可能的极端情况也是安全的代码。

    关于c# - MS Graph api : Timeout when converting docx to pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65069438/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com