Programmatically set WCF timeout in debug mode

You could do the following:

  • create the binding and the endpoint in code
  • set the timeouts on the binding instance
  • then create your client proxy using those two elements

Something like:

BasicHttpBinding myBinding = new BasicHttpBinding("ConfigName");
myBinding.CloseTimeout = .......
myBinding.OpenTimeout = .......
myBinding.ReceiveTimeout = .......
myBinding.SendTimeout = .......

EndpointAddress myEndpoint = new EndpointAddress("http://server:8181/yourservice");

YourServiceClient proxy = new YourServiceClient(myBinding, myEndpoint);

That way, you can leverage the basic config when describing binding timeouts and yet you can tweak the settings you want and create your client proxy from it.


You can create a second binding in the web.config and set a longer sendTimeout.

        if (debug)
        {
            proxy =  new MyClient("WSHttpBinding_MyLocal");
        }
        else
        {
            proxy = new MyClient("WSHttpBinding_MyDev");
        }

        <wsHttpBinding>
            <binding name="WSHttpBinding_MyLocal" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:20:00"

...