how to configure Protobuf-net Grpc to send and recieve large data

539 Views Asked by At

I was running a performance benchmark while sending/receiving data  using protobuf-net grpc (codefirst). I created a million records on the server and attempted to return to the client side, but received the following error:

Status(StatusCode="ResourceExhausted", Detail="Message received exceeded the maximum configured message size."

Well, the error makes sense because I am aware that there is a default limit of 4 mb.

so I modified the configuration in both server and client side but I'm still receiving the same error.

my configuration Server Side

builder.Services.AddCodeFirstGrpc(config =>
    {
        config.ResponseCompressionLevel = CompressionLevel.Optimal;
        config.EnableDetailedErrors = true;
        config.MaxSendMessageSize = null; //30000000
        config.MaxReceiveMessageSize = null;//30000000
    }   
); 

My Configuration in Client Side

builder.Services.AddCodeFirstGrpcClient<IGenericService>(x =>
{
    x.ChannelOptionsActions.Add(x => new GrpcChannelOptions
    {
        HttpHandler = hand,

        MaxReceiveMessageSize = null, //30000000
        MaxSendMessageSize = null, //30000000
        Credentials = ChannelCredentials.Insecure,
        UnsafeUseInsecureChannelCallCredentials = true,
        ServiceConfig = new ServiceConfig { LoadBalancingConfigs = { new RoundRobinConfig() } }
    }) ;
    
    x.Address = new Uri("http://localhost:5010");

})
.ConfigurePrimaryHttpMessageHandler(x => hand);

Client Side Libraries: Grpc.Net.Client - 2.49.0 Grpc.Net.Client.Web - 2.49.0 protobuf-net.Grpc.ClientFactory - 1.0.177

Server Side Libraries: Grpc.aspnetcore - 2.49.0 Grpc.aspnetcore.Web - 2.49.0 protobuf-net - 3.1.22 protobuf-net.grpc.aspnetcore - 1.0.177

Can't figure out what is wrong with my implementation, or maybe it's a bug? Not sure.

any help is much appreciated, Thanks

0

There are 0 best solutions below