Grpc.Net.Client 2.49.0

.NET 5.0 .NET Standard 2.0
NuGet\Install-Package Grpc.Net.Client -Version 2.49.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Grpc.Net.Client --version 2.49.0
<PackageReference Include="Grpc.Net.Client" Version="2.49.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Grpc.Net.Client --version 2.49.0
#r "nuget: Grpc.Net.Client, 2.49.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Grpc.Net.Client as a Cake Addin
#addin nuget:?package=Grpc.Net.Client&version=2.49.0

// Install Grpc.Net.Client as a Cake Tool
#tool nuget:?package=Grpc.Net.Client&version=2.49.0


Grpc.Net.Client is a gRPC client library for .NET.

Configure gRPC client

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

Make gRPC calls

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:

  • Unary
  • Server streaming
  • Client streaming
  • Bi-directional streaming

Unary call

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.

Server streaming call

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

Client streaming call

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

Bi-directional streaming call

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())
        // 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))

    await call.RequestStream.WriteAsync(new EchoMessage { Message = result });

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:

  1. Starts a new bi-directional streaming call by calling EchoClient.Echo.
  2. Creates a background task to read messages from the service using ResponseStream.ReadAllAsync().
  3. Sends messages to the server with RequestStream.WriteAsync.
  4. Notifies the server it has finished sending messages with RequestStream.CompleteAsync().
  5. Waits until the background task has read all incoming messages.

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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (440)

Showing the top 5 NuGet packages that depend on Grpc.Net.Client:

Package Downloads
Grpc.Net.ClientFactory The ID prefix of this package has been reserved for one of the owners of this package by

HttpClientFactory integration the for gRPC .NET client

Google.Api.Gax.Grpc The ID prefix of this package has been reserved for one of the owners of this package by

Additional support classes for Google gRPC API client libraries

OpenTelemetry.Exporter.OpenTelemetryProtocol The ID prefix of this package has been reserved for one of the owners of this package by

OpenTelemetry protocol exporter for OpenTelemetry .NET

Microsoft.Azure.Functions.Worker.Grpc The ID prefix of this package has been reserved for one of the owners of this package by

This library provides gRPC support for Azure Functions .NET Worker communication with the Azure Functions Host.


The Pulumi .NET SDK lets you write cloud programs in C#, F#, and VB.NET.

GitHub repositories (47)

Showing the top 5 popular GitHub repositories that depend on Grpc.Net.Client:

Repository Stars
Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 6, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
Documentation for ASP.NET Core
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0, 6.0 and 7.0 projects you can use. Readme contains explanations on all projects.
Version Downloads Last updated
2.49.0 171 9/26/2022
2.49.0-pre1 1,402 9/1/2022
2.48.0 220,263 8/24/2022
2.48.0-pre1 1,462 8/17/2022
2.47.0 639,829 7/3/2022
2.47.0-pre1 2,097 6/23/2022
2.46.0 1,570,691 5/13/2022
2.46.0-pre1 3,565 4/28/2022
2.45.0 756,267 4/19/2022
2.45.0-pre1 4,700 4/7/2022
2.44.0 809,986 3/17/2022
2.44.0-pre1 10,004 3/9/2022
2.43.0 2,421,664 2/25/2022
2.43.0-pre1 9,628 1/28/2022
2.42.0 1,434,744 1/19/2022
2.42.0-pre1 9,543 12/30/2021
2.41.0 1,197,920 12/7/2021
2.41.0-pre1 33,704 11/12/2021
2.40.0 3,052,535 10/5/2021
2.40.0-pre1 6,165 9/9/2021
2.39.0 1,369,954 8/18/2021
2.39.0-pre1 31,668 8/6/2021
2.38.0 2,011,909 6/11/2021
2.38.0-pre1 1,358 6/4/2021
2.37.0 4,129,645 4/20/2021
2.37.0-pre1 967 4/14/2021
2.36.0 1,122,503 3/17/2021
2.36.0-pre1 1,475 3/9/2021
2.35.0 1,250,729 2/4/2021
2.35.0-pre1 2,071 1/26/2021
2.34.0 2,516,551 12/11/2020
2.34.0-pre1 3,548 12/1/2020
2.33.1 1,384,008 10/28/2020
2.33.1-pre1 883 10/22/2020
2.32.0 5,407,829 10/5/2020
2.32.0-pre1 14,344 9/8/2020
2.31.0 981,225 8/14/2020
2.31.0-pre2 1,059 8/3/2020
2.30.0 482,171 7/16/2020
2.30.0-pre1 14,505 6/17/2020
2.29.0 866,112 5/27/2020
2.29.0-pre1 4,332 5/15/2020
2.28.0 665,643 4/9/2020
2.28.0-pre2 18,684 3/11/2020
2.28.0-pre1 7,486 3/3/2020
2.27.0 1,625,240 2/7/2020
2.27.0-pre1 25,071 1/24/2020
2.26.0 1,572,642 12/19/2019
2.26.0-pre1 931 12/10/2019
2.25.0 1,053,635 11/7/2019
2.25.0-pre1 833 11/1/2019
2.24.0 446,574 10/21/2019
2.24.0-pre1 2,053 10/9/2019
2.23.2 438,664 9/20/2019
0.2.23-pre2 11,435 9/6/2019
0.2.23-pre1 9,266 8/21/2019
0.1.22-pre3 7,203 7/30/2019
0.1.22-pre2 13,486 7/2/2019
0.1.22-pre1 3,679 6/17/2019
0.1.21-pre1 1,827 6/4/2019