public GrpcMonitor(string monitor) { // maxRpcMessageSize raises the gRPC Max Message size from `4194304` (4mb) to `419430400` (400mb) var maxRpcMessageSize = 400 * 1024 * 1024; var grpcChannelOptions = new List <ChannelOption> { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, maxRpcMessageSize) }; this._client = new ResourceMonitor.ResourceMonitorClient(new Channel(monitor, ChannelCredentials.Insecure, grpcChannelOptions)); }
public GrpcMonitor(string monitorAddress) { // Allow for insecure HTTP/2 transport (only needed for netcoreapp3.x) // https://docs.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-6.0#call-insecure-grpc-services-with-net-core-client AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); // maxRpcMessageSize raises the gRPC Max Message size from `4194304` (4mb) to `419430400` (400mb) const int maxRpcMessageSize = 400 * 1024 * 1024; if (_monitorChannels.TryGetValue(monitorAddress, out var monitorChannel)) { // A channel already exists for this address this._client = new ResourceMonitor.ResourceMonitorClient(monitorChannel); } else { lock (_channelsLock) { if (_monitorChannels.TryGetValue(monitorAddress, out var existingChannel)) { // A channel already exists for this address this._client = new ResourceMonitor.ResourceMonitorClient(monitorChannel); } else { // Inititialize the monitor channel once for this monitor address var channel = GrpcChannel.ForAddress(new Uri($"http://{monitorAddress}"), new GrpcChannelOptions { MaxReceiveMessageSize = maxRpcMessageSize, MaxSendMessageSize = maxRpcMessageSize, Credentials = ChannelCredentials.Insecure }); _monitorChannels[monitorAddress] = channel; this._client = new ResourceMonitor.ResourceMonitorClient(channel); } } } }
public GrpcMonitor(string monitor) { this._client = new ResourceMonitor.ResourceMonitorClient(new Channel(monitor, ChannelCredentials.Insecure)); }