We have a Grpc server implemented on c# .net 5.0 environment
public void ConfigureServices(IServiceCollection services)
{
...
services.AddGrpc(o =>
{
o.EnableDetailedErrors = true;
// Small performance benefit to not add catch-all routes to handle UNIMPLEMENTED for unknown services
o.IgnoreUnknownServices = true;
o.Interceptors.Add<CustomInterceptor>();
});
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider container, IHostApplicationLifetime lifetime)
{
...
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
});
});
...
}
We are using Server-Side streaming connection, to send client notifications
public override async Task Start(ConnectorRequest request, IServerStreamWriter<ClientNotification> clientStream,
ServerCallContext serverCallContext)
{
WaitHandle.WaitAny(new[] { context.CancellationToken.WaitHandle });
}
Client side implemented on mobile platforms. After tests we see that when client loses connection (for example turn off wifi) we don't have any exception or notification about it.
How to configure server to break stream connection when client lose connectivity. May be something like keep_alive settings. I found https://github.com/grpc/grpc/blob/master/doc/keepalive.md but I don't know where I should set it.