How do I increase the default timeout to larger than 1 minute on a WCF service?
-
What is not clear, but I think you are asking implicitly, is whether or not it is possible to configure on the server side to timeout any calls that take longer than one minute to process. [This is not possible](https://mohundro.com/blog/2011/08/19/wcf-and-service-side-timeouts/) – gravidThoughts Aug 01 '18 at 19:45
5 Answers
Are you referring to the server side or the client side?
For a client, you would want to adjust the sendTimeout attribute of a binding element. For a service, you would want to adjust the receiveTimeout attribute of a binding elemnent.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="longTimeoutBinding"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="longTimeoutService"
behaviorConfiguration="longTimeoutBehavior">
<endpoint address="net.tcp://localhost/longtimeout/"
binding="netTcpBinding" bindingConfiguration="longTimeoutBinding" />
</service>
....
Of course, you have to map your desired endpoint to that particular binding.
-
How do I map the binding, using 'bindingname' inside the endpoint tag? – Blankman Jan 08 '09 at 16:41
-
[This is simply wrong](https://www.rauch.io/2015/06/25/all-wcf-timeouts-explained/) The `receiveTimeout` on the server side governs determination of idleness for session based bindings. For example, the server won't use this setting for basicHTTP bindings.[You have to roll your own server side processing timeouts for WCF](https://mohundro.com/blog/2011/08/19/wcf-and-service-side-timeouts/) – gravidThoughts Aug 01 '18 at 19:41
-
As you can see from the config, it's a NetTcpBinding and not a BasicHttpBinding. – user2206916 Apr 28 '21 at 13:11
Under the Tools menu in Visual Studio 2008 (or 2005 if you have the right WCF stuff installed) there is an options called 'WCF Service Configuration Editor'.
From there you can change the binding options for both the client and the services, one of these options will be for time-outs.

- 26,748
- 16
- 78
- 122
-
The tool is a great way to go to avoid errors such as wrapping the elements up the wrong way, spelling, etc. Good call! – markaaronky Aug 24 '17 at 18:15
-
see also here for the other tool to open the log files: https://stackoverflow.com/a/34283667/187650 – juFo Feb 16 '18 at 08:01
You can choose two ways:
1) By code in the client
public static void Main()
{
Uri baseAddress = new Uri("http://localhost/MyServer/MyService");
try
{
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService));
WSHttpBinding binding = new WSHttpBinding();
binding.OpenTimeout = new TimeSpan(0, 10, 0);
binding.CloseTimeout = new TimeSpan(0, 10, 0);
binding.SendTimeout = new TimeSpan(0, 10, 0);
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
serviceHost.AddServiceEndpoint("ICalculator", binding, baseAddress);
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
}
catch (CommunicationException ex)
{
// Handle exception ...
}
}
2)By WebConfig in a web server
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding openTimeout="00:10:00"
closeTimeout="00:10:00"
sendTimeout="00:10:00"
receiveTimeout="00:10:00">
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
For more detail view the official documentations

- 13,072
- 12
- 67
- 75
Different timeouts mean different things. When you're working on the client.. you're probably looking mostly at the SendTimeout - check this reference - wonderful and relevant explanation: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/
It says:
Brief summary of binding timeout knobs...
Client side:
SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.
OpenTimeout and CloseTimeout are used when opening and closing channels (when no explicit timeout value is passed).
ReceiveTimeout is not used.
Server side:
Send, Open, and Close Timeout same as on client (for Callbacks).
ReceiveTimeout is used by ServiceFramework layer to initialize the session-idle timeout.

- 28,927
- 17
- 154
- 183

- 99
- 1
- 4
In addition to the binding timeouts (which are in Timespan
s), You may also need this as well. This is in seconds.
<system.web>
<httpRuntime executionTimeout="600"/><!-- = 10 minutes -->

- 3,708
- 1
- 26
- 45