Named pipe transport for gRPC in C#/.NET.
This is not an official Google product.
- .NET Framework 4.6.2+ (Windows)
- .NET 6+ (Windows, macOS, Linux)
Suppose you have a Greeter service as described in the gRPC on .NET Core intro.
Server:
var server = new NamedPipeServer("MY_PIPE_NAME");
Greeter.BindService(server.ServiceBinder, new GreeterService());
server.Start();
Client:
var channel = new NamedPipeChannel(".", "MY_PIPE_NAME");
var client = new Greeter.GreeterClient(channel);
var response = await client.SayHelloAsync(
new HelloRequest { Name = "World" });
Console.WriteLine(response.Message);
Named pipes are suitable for inter-process communication (IPC).
Since the introduction of this project, ASP.NET Core has added support for gRPC over Unix Domain Sockets and over Named Pipes. Here is a handy matrix to help you decide what's right for you:
GrpcDotNetNamedPipes | ASP.NET UDS | ASP.NET Named Pipes | ASP.NET HTTP | |
---|---|---|---|---|
.NET Platform | .NET Framework 4.6.2 .NET 5 |
.NET 5 | .NET 8 (server) .NET 5 (client) |
.NET 5 |
OS | Windows 7 Mac Linux |
Windows 10 Mac Linux |
Windows 7 | Windows 7 Mac Linux |
No firewall warnings | ✔️ | ✔️ | ✔️ | ❌ |
No network adapter | ✔️ | ✔️ | ✔️ | ❌ |
Access controls | ✔️ | ❌ | ✔️ | ❌ |
Binary size (trimmed) | ~ 300 KB | ~ 7 MB | ~ 7 MB | ~ 7 MB |
Startup time | < 25ms | < 25ms | < 25ms | ~ 250ms |
Large message throughput | ~ 500MB/s | ~ 400MB/s | ~ 100MB/s | ~ 100MB/s |
Streaming messages | ~ 400k/s | ~ 500k/s | ~ 500k/s | ~ 400k/s |
Method calls | ~ 8000/s | ~ 4000/s | ~ 5000/s | ~ 2500/s |
Compatible with gRPC-Go | ❌ | ✔️ | ✔️ | ✔️ |
Official Microsoft support | ❌ | ✔️ | ✔️ | ✔️ |
Performance numbers are based on tests running on Windows 11 with .NET 8.
This implementation currently uses a custom wire protocol so it won't be compatible with other gRPC named pipe implementations.
Linux and macOS support is provided for universal compatibility but may not be as optimized as Windows.