3

I'm struggling with setting the OperationTimeout on the RoutingService

The issue is that the service to which the message is forwarded needs more then 1 Minute to give a response. This causes an OperationTimeout Exception on the RoutingService.

I tried to set the OperationTimeout on the client proxy of the RoutingService without success.

What I did, is to add an Endpoint Behavior and add in the ApplyClientBehavior method an custom IClientMessageInspector.

In the custom ClientMessageInspector I set the OperationTimeout, like you see in this code snippet.

    public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
        var contextChannel = channel as IContextChannel;
        contextChannel.OperationTimeout = new TimeSpan(0, 10, 0);

        return request;
    }

For me it seems that I'm too late at this point and therefore the RoutingService generated proxy doesn't care about this setting, could this be ?

Any suggestions?

Artemix
  • 2,113
  • 2
  • 23
  • 34
Giulia Amato
  • 41
  • 1
  • 4
  • You don't need to include signature in your post - your user card is added automatically. Read [FAQ](http://stackoverflow.com/faq#signatures) for more details. – Artemix Dec 17 '12 at 16:22

2 Answers2

1

In web.config set SendTimeout in the below

<binding name="myBindingName" sendTimeout="00:10:00"
                 closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" 
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 crossDomainScriptAccessEnabled="true" />
Sameer Alibhai
  • 3,092
  • 4
  • 36
  • 36
lcryder
  • 486
  • 2
  • 8
  • I down-voted this post because while it works, it's very imprecise. See http://stackoverflow.com/a/5310933/249742 for details about timeouts used client side: in that case, the only timeout to change is sendTimeout. – Eric Boumendil Dec 12 '14 at 10:22
1

I found a solution how to solve this.

You just need to set the SendTimeout on the binding of the client endpoint of the router. When creating the proxy the router will set OperationTimeout=SendTimeout on it's channel.

            // add the endpoint the router uses to receive messages
            serviceHost.AddServiceEndpoint(
                 typeof(IRequestReplyRouter),
                 new BasicHttpBinding(), 
                 "http://localhost:8000/routingservice/router");

            // create the client endpoint the router routes messages to
            var client = new ServiceEndpoint(
                                            ContractDescription.GetContract(typeof(IRequestReplyRouter)), 
                                            new NetTcpBinding(),
                                            new EndpointAddress("net.tcp://localhost:8008/MyBackendService.svc"));

            // Set SendTimeout, this will be used from the router generated proxy as OperationTimeout
            client.Binding.SendTimeout = new TimeSpan(0, 10, 0);
Giulia Amato
  • 41
  • 1
  • 4