2017-10-06 1 views
0

두 WebApi간에 큰 (20GB) 파일을 보내는 데 문제가 있습니다. 내가 전송되는 전체 파일을 WebAPI2하는 우체부를 통해이 파일을 보내고 때 ASP.NET 4.6예기치 않은 요청 콘텐츠 끝 Kestrel ASP.NET 코어

WebAPI2 작성

WebAPI1는 ASP.NET Core 2.0

에 작성합니다. 그러나 WebAPI1에서 WebAPI2로 파일을 보내려고하면 (필자는 7GB와 같은 파일을 보낼 수 있습니다) 실패합니다.

20기가바이트 파일을 보내는 동안 나는 WebAPI2에서 오류가 발생하고있다 : 나는 WebApi1에서 WCF 계약의 일부로서이 요청을 실행하면

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected 
end of request content. 
    at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.PipeCompl 
etion.ThrowFailed() 
    at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.GetR 
esult(ReadResult& result) 
    at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.Micr 
osoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.IReadableBufferAwai 
ter.GetResult() 
    at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.ReadableB 
ufferAwaitable.GetResult() 
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.<ReadAs 
ync>d__22.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot 
ification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameRequestStream. 
<ReadAsyncInternal>d__21.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot 
ification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.AspNetCore.WebUtilities.BufferedReadStream.<EnsureBufferedAsync> 
d__37.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot 
ification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.<ReadAsync>d__36.M 
oveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot 
ification(Task task) 
    at System.IO.Stream.<CopyToAsyncInternal>d__27.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot 
ification(Task task) 

답변

0

내가 스택 트레이스있어 :

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 
    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 
    at System.Threading.Tasks.Task`1.get_Result() 

그러나 내가 그 예외를 발견 2 분 후에 항상 던졌습니다.

컨트롤러 메서드 (WebAPI1에서)의 일부로 20GB 파일을 보내려고 시도했는데 TaskCanceledException을 잡았습니다. 이 예외가 발생하면 IsCancellationRequestedfalse 인 경우 제한 시간 문제라는 것을 확인하여 시간 초과 문제를 알 수 있습니다. 여기 유용한 게시물 : 스택 트레이스 내 경우 TaskCanceledException에서 HttpClient - A task was cancelled?

false로 설정, 그래서 문제가 해결 10 분 제한 증가 HttpClient를

new HttpClient { Timeout = TimeSpan.FromMinutes(2) }; 

에서 타임 아웃을이었다.