The HTTP request to http //xxx has exceeded the allotted timeout.

Published on Sunday, November 27, 2011

We have a WCF application with Silverlight 4.0 client application. The system worked well but just sometimes we got the following error:

The HTTP request to http://xxx has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

We traced the bug using Visual Studio 2010 and got the following popup message:


There are some solutions on internet. most of cases start from add the following content in WCF’s web.config file or app.config file (self-host WCF):

      <binding name="BasicHttpBinding_ConspecService"    
        closeTimeout="00:10:00" >    

But, it will NOT help. the error still come.

**The final solution is “Specifies the maximum number of connections to a network host” **

The following code example configures an application to use four connections to the server www.???.com and 80 connections to all other servers.

In config file (WCF side):

<?xml version="1.0" encoding="utf-8" ?>   
      <add address="*" maxconnection="80"/>    
      <add address = http://www.???.com maxconnection = "4" />    

Or code behind (WCF side):

//how many outgoing connection that can make to a single endpoint. Default Value is 2   
System.Net.ServicePointManager.DefaultConnectionLimit = 80;