grpc / grpc/grpc-dotnet

Connection timeout vs Deadline

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

Description

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](https://github.com/grpc/grpc-dotnet/assets/27290512/4e5cd3fb-ced0-414a-83f1-b30b27a6e5f0)

If I setup Deadline >= 23sec the gRPC client call will return `Unavailable` status code.
(Deadline = 23sec in this example)
![image](https://github.com/grpc/grpc-dotnet/assets/27290512/9b861169-f7ff-47b5-9a56-c1273cbc49f5)

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.
```csharp
serviceCollection
.AddGrpcClient(option =>
{
option.Address = new Uri(configuration.EndpointAddress);
option.CallOptionsActions.Add(ctx =>
ctx.CallOptions =
ctx.CallOptions
.WithDeadline(DateTime.UtcNow.Add(configuration.Deadline)))
;
})
```

Contributor guide

Open the contributing guide

Research direction

Start with the gRPC client registration shown in the issue and investigate how connection timeout and CallOptions deadlines interact when the server is unavailable. The issue names no repository files or tests, so first identify the relevant client transport configuration and existing coverage, then determine whether consistent RpcException behavior is documented or reproducible.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.