![]() |
VOOZH | about |
dotnet add package Grpc.Net.Client --version 2.80.0
NuGet\Install-Package Grpc.Net.Client -Version 2.80.0
<PackageReference Include="Grpc.Net.Client" Version="2.80.0" />
<PackageVersion Include="Grpc.Net.Client" Version="2.80.0" />Directory.Packages.props
<PackageReference Include="Grpc.Net.Client" />Project file
paket add Grpc.Net.Client --version 2.80.0
#r "nuget: Grpc.Net.Client, 2.80.0"
#:package Grpc.Net.Client@2.80.0
#addin nuget:?package=Grpc.Net.Client&version=2.80.0Install as a Cake Addin
#tool nuget:?package=Grpc.Net.Client&version=2.80.0Install as a Cake Tool
Grpc.Net.Client is a gRPC client library for .NET.
gRPC clients are concrete client types that are generated from .proto files. The concrete gRPC client has methods that translate to the gRPC service in the .proto file. For example, a service called Greeter generates a GreeterClient type with methods to call the service.
A gRPC client is created from a channel. Start by using GrpcChannel.ForAddress to create a channel, and then use the channel to create a gRPC client:
var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client = new Greet.GreeterClient(channel);
A channel represents a long-lived connection to a gRPC service. When a channel is created, it's configured with options related to calling a service. For example, the HttpClient used to make calls, the maximum send and receive message size, and logging can be specified on GrpcChannelOptions and used with GrpcChannel.ForAddress. For a complete list of options, see client configuration options.
var channel = GrpcChannel.ForAddress("https://localhost:5001");
var greeterClient = new Greet.GreeterClient(channel);
var counterClient = new Count.CounterClient(channel);
// Use clients to call gRPC services
A gRPC call is initiated by calling a method on the client. The gRPC client will handle message serialization and addressing the gRPC call to the correct service.
gRPC has different types of methods. How the client is used to make a gRPC call depends on the type of method called. The gRPC method types are:
A unary call starts with the client sending a request message. A response message is returned when the service finishes.
var client = new Greet.GreeterClient(channel);
var response = await client.SayHelloAsync(new HelloRequest { Name = "World" });
Console.WriteLine("Greeting: " + response.Message);
// Greeting: Hello World
Each unary service method in the .proto file will result in two .NET methods on the concrete gRPC client type for calling the method: an asynchronous method and a blocking method. For example, on GreeterClient there are two ways of calling SayHello:
GreeterClient.SayHelloAsync - calls Greeter.SayHello service asynchronously. Can be awaited.GreeterClient.SayHello - calls Greeter.SayHello service and blocks until complete. Don't use in asynchronous code.A server streaming call starts with the client sending a request message. ResponseStream.MoveNext() reads messages streamed from the service. The server streaming call is complete when ResponseStream.MoveNext() returns false.
var client = new Greet.GreeterClient(channel);
using var call = client.SayHellos(new HelloRequest { Name = "World" });
while (await call.ResponseStream.MoveNext())
{
Console.WriteLine("Greeting: " + call.ResponseStream.Current.Message);
// "Greeting: Hello World" is written multiple times
}
When using C# 8 or later, the await foreach syntax can be used to read messages. The IAsyncStreamReader<T>.ReadAllAsync() extension method reads all messages from the response stream:
var client = new Greet.GreeterClient(channel);
using var call = client.SayHellos(new HelloRequest { Name = "World" });
await foreach (var response in call.ResponseStream.ReadAllAsync())
{
Console.WriteLine("Greeting: " + response.Message);
// "Greeting: Hello World" is written multiple times
}
A client streaming call starts without the client sending a message. The client can choose to send messages with RequestStream.WriteAsync. When the client has finished sending messages, RequestStream.CompleteAsync() should be called to notify the service. The call is finished when the service returns a response message.
var client = new Counter.CounterClient(channel);
using var call = client.AccumulateCount();
for (var i = 0; i < 3; i++)
{
await call.RequestStream.WriteAsync(new CounterRequest { Count = 1 });
}
await call.RequestStream.CompleteAsync();
var response = await call;
Console.WriteLine($"Count: {response.Count}");
// Count: 3
A bi-directional streaming call starts without the client sending a message. The client can choose to send messages with RequestStream.WriteAsync. Messages streamed from the service are accessible with ResponseStream.MoveNext() or ResponseStream.ReadAllAsync(). The bi-directional streaming call is complete when the ResponseStream has no more messages.
var client = new Echo.EchoClient(channel);
using var call = client.Echo();
Console.WriteLine("Starting background task to receive messages");
var readTask = Task.Run(async () =>
{
await foreach (var response in call.ResponseStream.ReadAllAsync())
{
Console.WriteLine(response.Message);
// Echo messages sent to the service
}
});
Console.WriteLine("Starting to send messages");
Console.WriteLine("Type a message to echo then press enter.");
while (true)
{
var result = Console.ReadLine();
if (string.IsNullOrEmpty(result))
{
break;
}
await call.RequestStream.WriteAsync(new EchoMessage { Message = result });
}
Console.WriteLine("Disconnecting");
await call.RequestStream.CompleteAsync();
await readTask;
For best performance, and to avoid unnecessary errors in the client and service, try to complete bi-directional streaming calls gracefully. A bi-directional call completes gracefully when the server has finished reading the request stream and the client has finished reading the response stream. The preceding sample call is one example of a bi-directional call that ends gracefully. In the call, the client:
EchoClient.Echo.ResponseStream.ReadAllAsync().RequestStream.WriteAsync.RequestStream.CompleteAsync().During a bi-directional streaming call, the client and service can send messages to each other at any time. The best client logic for interacting with a bi-directional call varies depending upon the service logic.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Grpc.Net.Client:
| Package | Downloads |
|---|---|
|
Grpc.Net.ClientFactory
HttpClientFactory integration the for gRPC .NET client |
|
|
Google.Api.Gax.Grpc
Additional support classes for Google gRPC API client libraries |
|
|
Serilog.Sinks.OpenTelemetry
This Serilog sink transforms Serilog events into OpenTelemetry logs and sends them to an OTLP (gRPC or HTTP) endpoint. |
|
|
Microsoft.Azure.Functions.Worker.Extensions.Rpc
Contains types to facilitate RPC communication between a worker extension and the functions host. |
|
|
Dapr.Client
This package contains the reference assemblies for developing services using Dapr. |
Showing the top 20 popular GitHub repositories that depend on Grpc.Net.Client:
| Repository | Stars |
|---|---|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
dotnet/eShop
A reference .NET application implementing an eCommerce site
|
|
|
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 11, 10, 9, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.
|
|
|
StockSharp/StockSharp
Algorithmic trading and quantitative trading open source platform to develop trading robots (stock markets, forex, crypto, bitcoins, and options).
|
|
|
Richasy/Bili.Uwp
适用于新系统UI的哔哩
|
|
|
FastEndpoints/FastEndpoints
A light-weight REST API development framework for ASP.NET 8 and newer.
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
|
|
|
dotnet/tye
Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
|
|
|
protobuf-net/protobuf-net
Protocol Buffers library for idiomatic .NET
|
|
|
Cysharp/MagicOnion
Unified Realtime/API framework for .NET platform and Unity.
|
|
|
open-telemetry/opentelemetry-dotnet
The OpenTelemetry .NET Client
|
|
|
Arcenox-co/TickerQ
TickerQ is a fast, reflection-free background task scheduler for .NET built with source generators, EF Core integration, cron + time-based execution, and a real-time dashboard.
|
|
|
Azure-Samples/cognitive-services-speech-sdk
Sample code for the Microsoft Cognitive Services Speech SDK
|
|
|
linq2db/linq2db
Linq to database provider.
|
|
|
thepirat000/Audit.NET
An extensible framework to audit executing operations in .NET
|
|
|
ClassIsland/ClassIsland
一款功能强、可定制、跨平台,适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。
|
|
|
phongnguyend/Practical.CleanArchitecture
Full-stack .Net 10 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 21, React 19, Vue 3.5, BFF with YARP, NextJs 16, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, EF Core, OpenTelemetry, SignalR, Background Services, Health Checks, Rate Limiting, Clouds (Azure, AWS, GCP), ...
|
|
|
ProtonVPN/win-app
Official ProtonVPN Windows app
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.80.0 | 2,463,766 | 4/30/2026 |
| 2.80.0-pre1 | 2,895 | 4/1/2026 |
| 2.76.0 | 14,352,529 | 12/19/2025 |
| 2.76.0-pre1 | 16,498 | 11/13/2025 |
| 2.71.0 | 47,017,930 | 4/25/2025 |
| 2.71.0-pre1 | 18,959 | 4/16/2025 |
| 2.70.0 | 27,884,324 | 3/10/2025 |
| 2.70.0-pre1 | 10,764 | 2/26/2025 |
| 2.67.0 | 22,594,437 | 11/21/2024 |
| 2.67.0-pre1 | 21,038 | 10/22/2024 |
| 2.66.0 | 30,975,078 | 9/20/2024 |
| 2.66.0-pre1 | 12,204 | 9/6/2024 |
| 2.65.0 | 45,931,128 | 7/27/2024 |
| 2.65.0-pre1 | 3,289 | 7/20/2024 |
| 2.64.0 | 2,245,182 | 7/19/2024 |
| 2.64.0-pre1 | 35,483 | 7/15/2024 |
| 2.63.0 | 13,763,330 | 5/24/2024 |
| 2.63.0-pre1 | 24,764 | 5/8/2024 |
| 2.62.0 | 31,818,027 | 3/29/2024 |
| 2.62.0-pre1 | 11,224 | 3/8/2024 |