Windows Form 용으로 사용할 Servie Framework 를 개발 중입니다.
.Net 6에서 gRPC로 Application(Bussines Logic) 및 File Transmit 관련 서비스를 작업하였습니다.
서비스 호출 구조가 Client <-> Nginx ReverseProxy <-> ASP.NET Core Server? 형태로 되어 있습니다.
File Upload 작업을 완료 후 디버깅시에는 이상이 없으나 배포하여 테스트 하는 경우 아래의 오류가 발생하였습니다.
* System.Net.Http.Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'INTERNAL_ERROR' (0x2).
이벤트 유형 모니커 이벤트 시간 기간 스레드
예외 throw됨: 'Grpc.Core.RpcException'(System.Private.CoreLib.dll("Status(StatusCode="Unavailable", Detail="Error starting gRPC call. IOException: The request was aborted. Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'INTERNAL_ERROR' (0x2).", DebugException="System.IO.IOException: The request was aborted.
---> System.Net.Http.Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'INTERNAL_ERROR' (0x2).
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.ThrowRequestAborted(Exception innerException)
at System.Net.Http.Http2Connection.Http2Stream.CheckResponseBodyState()
at System.Net.Http.Http2Connection.Http2Stream.TryReadFromBuffer(Span`1 buffer, Boolean partOfSyncRead)
at System.Net.Http.Http2Connection.Http2Stream.ReadDataAsync(Memory`1 buffer, HttpResponseMessage responseMessage, CancellationToken cancellationToken)
at Grpc.Net.Client.StreamExtensions.ReadMessageAsync[TResponse](Stream responseStream, GrpcCall call, Func`2 deserializer, String grpcEncoding, Boolean")) 예외 throw됨: 'Grpc.Core.RpcException'(System.Private.CoreLib.dll("Status(StatusCode="Unavailable", Detail="Error starting gRPC call. IOException: The request was aborted. Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'INTERNAL_ERROR' (0x2).", DebugException="System.IO.IOException: The request was aborted.
---> System.Net.Http.Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'INTERNAL_ERROR' (0x2).
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.ThrowRequestAborted(Exception innerException)
at System.Net.Http.Http2Connection.Http2Stream.CheckResponseBodyState()
at System.Net.Http.Http2Connection.Http2Stream.TryReadFromBuffer(Span`1 buffer, Boolean partOfSyncRead)
at System.Net.Http.Http2Connection.Http2Stream.ReadDataAsync(Memory`1 buffer, HttpResponseMessage responseMessage, CancellationToken cancellationToken)
at Grpc.Net.Client.StreamExtensions.ReadMessageAsync[TResponse](Stream responseStream, GrpcCall call, Func`2 deserializer, String grpcEncoding, Boolean")) 하이퍼링크: 기록 디버깅 활성화 12.49s [13276] 주 스레드
인터넷을 뒤져보니 딱히 해결책이 보이지 않더군요. (혹시 nginx 설정으로 변경할 수 있는 내용이 있으면 알려 주세요!)
그래서 어쩔수 없이 서비스를 변경하였습니다.
기존 서비스는 Request는 stream, Response static? buffer? 형태로 받고 있었습니다.
반환시 문제가 생기는 것 같아 Request 및 Reponse를 모두 Stream 으로 변경 후 오류 없이 사용 중입니다.
- .proto
service FileSVC {
rpc Download (RequestFileDownload) returns (stream ResponseFileDownload);
// 변경 전
//rpc Upload (stream RequestFileUpload) returns (ResponseFileUpload);
// 변경 후
rpc Upload (stream RequestFileUpload) returns ( stream ResponseFileUpload);
}