Skip to content

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

@nkraman0

Description

@nkraman0

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions