grpc/grpc-dotnet

Connection timeout vs Deadline

magiino opened this issue · 0 comments

Hello,

How can I configure socket connection timeout for grpc client?
If grpc server is down the connection will timeout after some time, according my measurements it is almost 23sec.

If I setup Deadline < 23sec the gRPC client call will return RpcException with DeadlineExceeded status code.
(Deadline = 22sec in this example)
image

If I setup Deadline >= 23sec the gRPC client call will return Unavailable status code.
(Deadline = 23sec in this example)
image

I need to control also socket connection timeout in order to get always the same behavior. Right now I get 2 different RpcExceptions based on Deadline.

This is my grpc client registration.

serviceCollection
  .AddGrpcClient<TGrpcClientType>(option =>
  {
      option.Address = new Uri(configuration.EndpointAddress);
      option.CallOptionsActions.Add(ctx =>
          ctx.CallOptions =
              ctx.CallOptions
                  .WithDeadline(DateTime.UtcNow.Add(configuration.Deadline)))
                  ;
  })