Hi All,
I have two questions. (these are unary calls)
1) While using synchronous gRPC calls, how should I find out when the Server goes down? Apparently, there is no exception thrown and the client C# code (generated by protoc and grpc extension) keeps polling for Server to get up.
2) If I use asyn call, whats the best way to find out, when the Server goes down or the application ran to completion. I am using following approach of sleep and polling but I am sure this is not the best way to get it done.
var client = GetDiscount.NewClient(channel);
var ctokenSource = new CancellationTokenSource();
var data = client.GetDealsAsync(new ModelAndCityId { CityId = 1, ModelId = 1 }, null, null, ctokenSource.Token);
while (!data.ResponseAsync.IsCompleted)
{
System.Threading.Thread.Sleep(waitTime);
waitTime += waitTimeIncement;
if (waitTime >= 50)
{
ctokenSource.Cancel(true);
data.Dispose();
CustomGRPCLoadBalancer.SetServerAsNotReachable(channel.ResolvedTarget);
channel.ShutdownAsync().Wait();
dataReceivedSuccessfully = false;
break;
}
}
Please pardon me if I am missing something basic as I am still pretty immature with gRPC and protobuf. If you can point me to the sources where i can learn more about such things then that will be great.