'How can I detect incoming keep-alive pings on a C# gRPC server?
According to the Performance Best Practices from the official gRPC website keep-alive pings should be used to keep HTTP/2 connections alive.
These best practices for gRPC are also talked about in the MS Docs, with the following code example on how to create a gRPC channel with a keep-alive ping:
var handler = new SocketsHttpHandler
{
PooledConnectionIdleTimeout = Timeout.InfiniteTimeSpan,
KeepAlivePingDelay = TimeSpan.FromSeconds(60),
KeepAlivePingTimeout = TimeSpan.FromSeconds(30),
EnableMultipleHttp2Connections = true
};
var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions
{
HttpHandler = handler
});
This works fine, but how can I detect those incoming keep-alive pings on the server? Can I use them in server-side code to detect if a connection to a client broke down? Are there other ways to detect connection issues in a gRPC channel?
It seems to me like those pings get frequently transmitted in the established TCP connection of the gRPC channel, but without any interface to access them like a "classical gRPC stream" would have.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
