Vicky
Vicky

Reputation: 1117

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.

Upvotes: 3

Views: 1270

Answers (1)

Ashish Negi
Ashish Negi

Reputation: 5301

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

Upvotes: 4

Related Questions