1 | initial version |
To set up gRPC preferences such as MaxReceiveMessageSize in .NET Framework, you can perform the following steps:
public class MyServer : MyService.MyServiceBase {...}
public class MyClient : MyService.MyServiceClient {...}
var server = new Server { Services = { MyService.BindService(new MyServer()) }, Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) },
// Set maximum receive message size
MaxReceiveMessageSize = 100 * 1024 * 1024
};
var channel = new Channel("localhost", Port, ChannelCredentials.Insecure, new[] { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) }); var client = new MyService.MyServiceClient(channel);
// Set maximum receive message size client.CallOptions = client.CallOptions.WithMaxReceiveMessageSize(100 * 1024 * 1024);
Note: In the above code, "Port" is the port number you want to use for your gRPC server.
With these steps, you can successfully set up gRPC preferences such as MaxReceiveMessageSize in .NET Framework.