Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a timeout for a service remoting call in service fabric

I have a service fabric service which i call like this from another service :

var checkerProxy = new ServiceProxyFactory<ICheck>(uri);
var checker = checkerProxy.CreateSingletonServiceProxy();
success = await checker.CheckMe();

I want to abort the call if it takes longer than a timeout.

How do I set timeout for a remoting call in service fabric ?

Edit 1 : note i can do something like this :

success = checker.CheckMe().Wait(TimeSpan.FromSeconds(10));

but this will not abort the remoting call, but only stop waiting for the completion of the task upon a timeout and i do not have the return value.

like image 996
Vicky Avatar asked Dec 17 '25 06:12

Vicky


1 Answers

You can set timeout in proxy using FabricTransportRemotingSettings :

            FabricTransportRemotingSettings settings = new FabricTransportRemotingSettings();
            settings.OperationTimeout = TimeSpan.FromMinutes(5);

            return new ServiceProxyFactory(
                (h) =>
                {
                    return new FabricTransportServiceRemotingClientFactory(settings);
                });
like image 59
Ashish Negi Avatar answered Dec 19 '25 20:12

Ashish Negi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!