microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Encountering a System.Threading.Tasks.TaskCanceledException while uploading 1.5 GB Office files

Open
#2,845 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

We are simulating a production-level workload by uploading large files. Specifically, we have been attempting to upload 1.5 GB files to the container, but we consistently face timeout errors or closed connection errors. We are using Graph SDK v5.34.0 for this task.

Error Details:

Error 1 :

              The System.Threading.Tasks.TaskCanceledException with a System.TimeoutException indicates that the request was canceled because it exceeded the configured HttpClient.Timeout of 100 seconds.

Solution : Increased the timeout period to 300 seconds and get the second error.

Error 2:

Test method RaaSDocumentManagement.Net8.Tests.BulkFile_Upload.AuditDrive_UploadFile threw exception:
System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.

Stack Trace: 
AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
IValueTaskSource.GetResult(Int16 token)
SslStream.g__CompleteWriteAsync|157_1[TIOAdapter](ValueTask writeTask, Byte[] bufferToReturn)
SslStream.WriteAsyncChunked[TIOAdapter](ReadOnlyMemory1 buffer, CancellationToken cancellationToken) SslStream.WriteAsyncInternal[TIOAdapter](ReadOnlyMemory1 buffer, CancellationToken cancellationToken)
Stream.g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
BufferedFileStreamStrategy.CopyToAsyncCore(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
HttpContent.g__WaitAsync|56_0(ValueTask copyTask)
--- End of inner exception stack trace ---
HttpContent.g__WaitAsync|56_0(ValueTask copyTask)
HttpConnection.SendRequestContentAsync(HttpRequestMessage request, HttpContentWriteStream stream, Boolean async, CancellationToken cancellationToken)
HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
HttpClientRequestAdapter.GetHttpResponseMessage(RequestInformation requestInfo, CancellationToken cancellationToken, Activity activityForAttributes, String claims, Boolean isStreamResponse)
HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken)
ContentRequestBuilder.PutAsync(Stream body, Action`1 requestConfiguration, CancellationToken cancellationToken)
BulkFile_Upload.AuditDrive_UploadFile() line 140
ThreadOperations.ExecuteWithAbortSafety(Action action)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with BulkFile_Upload.AuditDrive_UploadFile at line 140 and the ContentRequestBuilder.PutAsync call in the stack trace. Reproduce the 1.5 GB upload using Graph SDK v5.34.0, first with the 100-second timeout and then with 300 seconds, while comparing the timeout and forcibly closed connection errors. The issue does not define a specific expected fix or completion condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.