This repository is a proof of concept (POC) demonstrating how to implement and test different gRPC communication patterns in .NET, including:
- ✅ Unary gRPC
- ✅ Server‑side streaming
- ✅ Bi‑directional streaming
- ✅ JSON Transcoding (gRPC ↔ REST)
The solution also includes a .NET Console–based gRPC client used to test streaming scenarios that are not easily testable via browsers or REST tools.
The solution contains two projects:
GrpcService.sln
│
├── GrpcService # gRPC Server (.NET)
│ ├── Protos
│ │ └── v1
│ │ ├── auth.proto
│ │ ├── greet.proto
│ │ ├── stream.proto
│ │ └── bidirectional.proto
│ │
│ ├── Services
│ │ ├── AuthService.cs
│ │ ├── GreeterService.cs
│ │ ├── LocationService.cs
│ │ └── LocationTrackerService.cs
│ │
│ ├── appsettings.json
│ └── Program.cs
│
└── GrpcLocationClient # gRPC Client (.NET Console App)
├── Clients
│ ├── Interfaces
│ │ └── IClient.cs
│ ├── BidirectionalStreamClient.cs
│ └── ServerStreamClient.cs
│
├── Protos
│ └── v1
│ ├── stream.proto
│ └── bidirectional.proto
│
└── Program.cs
- Request–Response communication
- Implemented in
AuthService - Used for JWT authentication
Client → Request → Server
Client ← Response ← Server
Unary gRPC is exposed as a REST endpoint using JSON Transcoding.
import "google/api/annotations.proto";
service Authorizer {
rpc JwtAuth (AuthRequest) returns (AuthResponse) {
option (google.api.http) = {
post: "/api/v1/auth",
body: "*"
};
}
}✅ Can be tested via:
- Postman (gRPC protocol)
- Web browser / REST client (HTTP)
- Client sends one request
- Server sends multiple responses as a stream
Client → Request
Server → Stream(Response)
Used to demonstrate scenarios like:
- Continuous updates
- Notifications
- Data feeds
Tested via the Console gRPC Client.
- Client and server send streams simultaneously
- Full‑duplex communication over a single HTTP/2 connection
Client ⇄ Server (Streams in both directions)
Example use case implemented:
- Client sends live user location (lat, long, id)
- Server streams back nearby bus locations
This pattern is ideal for:
- Real‑time tracking
- Live maps
- IoT & telemetry systems
Tested via a .NET Console gRPC Client.
- ✅ Postman (gRPC)
- ✅ REST via JSON Transcoding
- ✅ Browser (HTTP endpoint)
- ❌ Not supported via REST / browsers
- ✅ Tested using .NET Console Client
The client application contains separate implementations for:
- Server‑side streaming
- Bi‑directional streaming
Streaming gRPC requires:
- Persistent HTTP/2 connections
- Open streams for continuous data flow
These features are not supported by typical REST tools or browsers, so a native gRPC client is required for:
- Server‑side streaming
- Bi‑directional streaming
- .NET (ASP.NET Core gRPC)
- gRPC
- Protocol Buffers (proto3)
- JSON Transcoding
- HTTP/2
- Swagger / OpenAPI (for transcoded HTTP APIs)
- Postman (for gRPC testing)
- Protobuf files are versioned under
Protos/v1 - JSON Transcoding is intentionally applied only to unary gRPC
- Streaming endpoints are pure gRPC by design
- Swagger UI is enabled only for transcoded unary gRPC endpoints
This project integrates JSON Transcoding to expose selected unary gRPC endpoints as traditional HTTP APIs.
builder.Services
.AddGrpc()
.AddJsonTranscoding();Swagger is enabled to visualize and test HTTP-mapped unary gRPC endpoints:
builder.Services.AddGrpcSwagger();
builder.Services.AddSwaggerGen();In development mode:
- Swagger UI is available for HTTP APIs
- gRPC Reflection is enabled for Postman and tooling support
if (app.Environment.IsDevelopment())
{
app.MapGrpcReflectionService().AllowAnonymous();
app.UseSwaggerUI();
}- ❌ Server-side streaming and bi-directional streaming cannot be exposed via JSON Transcoding
- ❌ Swagger UI does not support streaming gRPC
- ✅ JSON Transcoding is suitable only for unary gRPC
This design keeps streaming endpoints efficient and protocol-pure while still offering REST compatibility where needed.
- Authentication & authorization for streaming endpoints
- gRPC‑Web support for browser clients
- Redis / Geo‑spatial integration for location queries
- Observability (logging, metrics, tracing)
Refer to the attached screenshot for a visual overview of the solution structure and architecture.
This POC demonstrates:
- Proper separation of gRPC server and client
- Real‑world usage of all major gRPC patterns
- Practical JSON Transcoding integration
- Streaming‑first design for real‑time systems
It serves as a solid foundation for building production‑grade, real‑time gRPC‑based systems in .NET.