Tell me more: Which gRPC implementation is best for .NET/C# development?
gRPC supports several development languages and platforms. There are two gRPC implementations that integrate with .NET/C# development languages and communicate with the gRPC wire protocol. They are commonly referred to by their NuGet package names: Grpc.Core and grpc-dotnet.
- Grpc.Core
- This is the original gRPC C# implementation released in 2016.
- It is based on the C core native library (there was no usable C# HTTP/2 library in 2016).
- Supported platforms are:
- .NET Core on Linux, Windows and Mac OS X.
- .NET Framework 4.5+ (Windows).
- Mono 4+ on Linux, Windows and Mac OS X.
- This implementation should not be used for new development projects. gRPC announced in May 2021 their intention to phase out this implementation.
- grpc-dotnet
- This implementation is the recommended gRPC implementation for .NET/C#.
- It was released in September 2019 and uses the HTTP/2 protocol implementation added in .NET Core 3 and ASP.NET Core 3. It is not based on the gRPC C core native library.
- There are two NuGet packages, depending if the application is calling gRPC services (i.e. the gRPC client) or the application is hosting the gRPC services (i.e. the gRPC Server):
- Grpc.Net.Client package
- Supports gRPC calls over HTTP/2 on .NET Core 3 and .NET 5 or later.
- .NET Framework has limited support for gRPC over HTTP/2. It is possible using the WinHttpHandler component, which is only available in newer version of .NET Framework.
- Grpc.AspNetCore package
- gRPC services are hosted within the ASP.NET Core framework (requiring .NET Core 3.x or later).
- All built-in ASP.NET Core servers are supported. (i.e. Kestrel, TestServer, IIS, HTTP.sys). There is some support for Azure services.
- gRPC on ASP.NET Core integrates with standard ASP.NET Core features like logging, dependency injection (DI), authentication, and authorization.
- Grpc.Net.Client package
gRPC uses the HTTP/2 protocol. There can be situations where HTTP/2 is not supported, either by the application or the network infrastructure. There is a gRPC-Web NuGet package that can be used by browser applications and in networks without complete support for HTTP/2. gRPC-Web incorporates a modified gRPC protocol and wire-format that is compatible with HTTP/1.1. As a result, gRPC-Web does not support gRPC features client streaming and bidirectional streaming (because HTTP/1.1 only supports one-way communications). The initial support is with JavaScript, and there are plans to support language-specific web frameworks.
In May 2021, gRPC announced grpc-dotnet is the recommended gRPC implementation for .NET/C#.
- Core has entered maintenance mode. No new features or enhancements will be added. Important bug and security issues will continue to be addressed.
- As of May 2023 (previously May 2022), Grpc.Core will no longer officially be supported. Core NuGet packages will remain available, but no more fixes will be provided (including security fixes).
- Migrating from Grpc.Core to grpc-dotnet should be minimal since both implementations share the same API for invoking and handling RPCs. The way gRPC channels and servers are configured are different.
Contact us for more information.