C#/기초
[C#] gRPC Exception
딸기우유중독
2025. 1. 14. 14:50
Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")
https://learn.microsoft.com/ko-kr/aspnet/core/grpc/error-handling?view=aspnetcore-9.0
.NET에서 gRPC를 사용한 오류 처리
.NET에서 gRPC를 사용하여 오류 처리를 수행하는 방법을 알아봅니다.
learn.microsoft.com
Status(StatusCode="ResourceExhausted", Detail="Received message exceeds the maximum configured message size.")
Server
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc(options =>
{
options.EnableDetailedErrors = true;
options.MaxReceiveMessageSize = 2 * 1024 * 1024; // 2 MB
options.MaxSendMessageSize = 5 * 1024 * 1024; // 5 MB
});
}
Client
static async Task Main(string[] args)
{
var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions
{
MaxReceiveMessageSize = 5 * 1024 * 1024, // 5 MB
MaxSendMessageSize = 2 * 1024 * 1024 // 2 MB
});
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
}
https://learn.microsoft.com/en-us/aspnet/core/grpc/configuration?view=aspnetcore-9.0
gRPC for .NET configuration
Learn how to configure gRPC for .NET apps.
learn.microsoft.com
728x90