9

I get a Microsoft.Graph.ServiceExceptionwith Code: timeout Message: The request timed out. in Microsoft.Graph.Core with the following stack trace:

   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

The server returns the following headers:

"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"

Server response:

"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# code:

var queryOptions = new List<QueryOption> { new QueryOption('format', 'pdf') };
var pdf = await graphClient.Drives[folderId]
                           .Items[docxId]
                           .Content
                           .Request(queryOptions)
                           .GetAsync();

Usually this code works but every other day it times out. If it only times out once that would be ok but some users experience multiple timeouts in a row so even retrying does not help.

Is there a way to get more information about this issue? Do I have access to logs / more detailed error messages somewhere?

Marius
  • 1,529
  • 6
  • 21
  • (1) Share the response (timestamp, requestid) for analysis (2) how big is the docx file? (3) Can you able to open the docx file (where you face the issue) in OneDrive/Sharepoint/Word Online without any problem? – Dev Nov 30 '20 at 10:46
  • (4) outside of your code can you repro the issue using Graph Explorer or POSTMAN for the given user as well? – Dev Nov 30 '20 at 10:47
  • @Dev: (1): Please see the server response and headers in the question (I edited the question to add them). I think "X-CorrelationId" should be the Request Id (?) and the Timestamp is the Date in the response. (2) The docx is 300 KB. (3) Yes, I can always open the document in Sharepoint without any problems. (4) No, I can not reproduce the error outside of the application because it only fails sometimes. I just tried it and it worked. – Marius Nov 30 '20 at 13:37
  • @Dev: There is another timestamp in "Ref C" in the "X-MSEdge-Ref" header. The timestamp "Date" in the response is from when the request ended. – Marius Nov 30 '20 at 13:46
  • Thanks for the update @Marius. In such scenario, i would do a re-try and it had helped moving forward. I would suggest you to give a try to see if it helps. – Dev Nov 30 '20 at 15:58
  • If you look at the backend logs then they're meant only for their consumptions. If you still need more info/assistance to check these logs, then you can check with Microsoft Support. – Dev Dec 04 '20 at 13:34
  • If you still face issue then you can try this - (1) Make sure the doc file is not locked or used by other users, which might be related to deadlock scenario (2) as you say with multiple users then i would suggest you to reduce the number of users in smaller numbers who're calling the API and see if it happens only due to the huge number of users making concurrent calls. – Dev Dec 04 '20 at 13:36
  • Intermittent issues are complex, tough to handle, unless we see a pattern whether it happens within a given point of time or set of users or when you perform say 'x' number of calls it fails. Being said that, just wanted to check whether the above helped you? – Dev Dec 05 '20 at 04:19
  • @Dev re: backend logs: Unfortunately I got this response from Microsoft support: "Developer support for desktop technologies and the Office 365 suite is currently offered to Microsoft Unified Support and Premier customers." – Marius Dec 07 '20 at 09:40
  • @Dev re (1): I tested what happens if another user has the document open at the same time and the conversion worked without any problems. (2) We only have a very small number of users and an even smaller number of users which use the service at the same time. – Marius Dec 07 '20 at 11:03
  • Aah. (1) Another suggestion i have is to process the less number of docs at the time, instead of bulk. This will reduce the timeouts a lot. (2) Implement JSON batching to see if it helps to handle your scenario. (3) I see that you're using GraphClient, you can use overalltimeout property to see you can increase the timeout for the GraphClient and not for the API call. If something above helps, let me know - i will move this to answer and you can consider upvote for me... – Dev Dec 07 '20 at 19:28
  • Collated all the above info to answer. Consider upvoting it, if it helped you; so it can be useful to others as well. – Dev Dec 08 '20 at 18:14

2 Answers2

2
  1. In case of a lot of data that coused timeout exception, you need use in Paging. see more in: https://learn.microsoft.com/en-us/graph/paging2

  2. You can increase the time out by set it:

    graphClient.HttpProvider.OverallTimeout = TimeSpan.FromHours(1);

Both of the above options can solve your problem, but even if they do not they are a safe code for possible extreme cases.

user1012506
  • 2,048
  • 1
  • 26
  • 45
0
  • Do Re-try and it workes for few, but still we see the issue.
  • Make sure the doc file is not locked or used by other users, which might be related to deadlock scenario
  • As you say with multiple users then i would suggest you to reduce the number of users in smaller numbers who're calling the API and see if it happens only due to the huge number of users making concurrent calls
  • Process the less number of docs at the time, instead of bulk. This will reduce the timeouts a lot.
  • Implement JSON batching to see if it helps to handle your scenario.
  • I see that you're using GraphClient, you can use overalltimeout property to see you can increase the timeout for the GraphClient and not for the API call.
Dev
  • 2,428
  • 2
  • 14
  • 15