Search⌘ K
AI Features

Server-Streaming gRPC Calls

Explore how server-streaming gRPC calls function by sending multiple messages from a server to a client in real time. Understand the implementation details on both server and client sides using ASP.NET Core, including working with streams to receive continuous live updates without polling. This lesson covers practical coding examples to help you manage live data streams effectively in gRPC applications.

A server-streaming call works by sending a stream of messages from the server back to the client instead of just supplying a single response. The client will still need to trigger the stream by sending its initial request to the server. Then the server can open the stream and write any arbitrary number of messages into it.

Message exchange in server-streaming gRPC calls
Message exchange in server-streaming gRPC calls

Server streaming can be used in scenarios where the client would expect the server to deliver multiple live data updates. For example, we might want to monitor train updates while waiting for a train at the station. We can request access to the live timetable and then receive live updates if there are any new arrivals, delays, or cancellations. With server streaming, we don't have to keep polling the server for new updates.

Streaming is different from populating a collection of objects and returning it. The client doesn't need to wait for the code on the server to finish executing. Any item that the ...