Search code examples
c#timeoutazure-service-fabricremoting

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.


Solution

  • 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);
                    });