grpc / grpc/grpc-dotnet

Definative guidance for keepalive using gRPC server side streaming

Open
#2,588 1 comment 6 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

I am hoping to get my head around server side keepalive settings in grpc-dotnet.

### Scenario

Push based notifications. The client starts a streaming call which they expect to be long lived (for the duration of the program). The server can send push notifications via streaming to the client. The stream can become idle for long periods of time if there are no new notifications to be sent, but the connection should still be kept "warm".

This is running in an environment with a network firewall that will kill connections without traffic for an hour.

In this case, I have an ASP.NET 8 Server, and a Python Client.

### Problem

I can't find definitive guidance on how to configure both sides for the above scenario. I am getting an error on the client after an hour of inactivity:
```
status = StatusCode.UNAVAILABLE
details = "Socket closed"
debug_error_string = "UNKNOWN:Error received from peer"
```

I have done a fair amount of extra reading:

- https://grpc.io/docs/guides/keepalive/
- https://learn.microsoft.com/en-us/aspnet/core/grpc/performance?view=aspnetcore-8.0#keep-alive-pings
- https://github.com/grpc/grpc-dotnet/issues/2313
- https://github.com/grpc/grpc-dotnet/issues/770
- https://github.com/grpc/grpc-dotnet/issues/1096
- https://github.com/grpc/grpc-dotnet/issues/577
- https://github.com/dotnet/aspnetcore/issues/15104

gRPC docs highlight the importance of server and client settings being configured together. What I find somewhat confusing is that many of the keepalive configurations do not seem to be settable via the ASP.NET server e.g:
- keepalive_time_ms
- keepalive_permit_without_calls
- max_pings_without_data

It seems the explanation for this is that Kestrel handles keepalive itself (which I think is enabled by default?). My confusion probably stems from my lack of understanding about Kestrel. But I would appreciate it if someone could point me in the right direction.

Contributor guide

Open the contributing guide

Research direction

Start with the gRPC keepalive guide, the ASP.NET Core keep-alive documentation, and the referenced grpc-dotnet issues, then compare the ASP.NET 8 server and Python client settings described here. Done means documenting definitive compatible guidance for long-lived server-streaming calls behind an idle connection firewall, including which settings Kestrel exposes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, grpc, python
Domain
backend-api-design, documentation, networking
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.