Reputation: 151
I am new to Grpc call.
Currently, I am using Grpc.Core to make a new instance of a "Channel". Please see code below.
Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
Now, I want to add a connection timeout in the creation of the channel. Is that possible for Grpc.Core?
I know it is possible to add options in using "Grpc.Net.Client." However, it will only work for .Net Core 2.1 and my project is not targeting that framework. https://learn.microsoft.com/en-us/aspnet/core/grpc/performance?view=aspnetcore-5.0
Upvotes: 1
Views: 3367
Reputation: 1674
A channel doesn't connect until an RPC has been called. You can explicitly request a channel to connect with a timeout deadline ahead of time if you want using ConnectAsync.
See the documentation at https://grpc.github.io/grpc/csharp/api/Grpc.Core.Channel.html#Grpc_Core_Channel_ConnectAsync_System_Nullable_System_DateTime__.
Upvotes: 1