Note that there are some explanatory texts on larger screens.

plurals
  1. POCalls to WCF Service occasionally hang
    primarykey
    data
    text
    <p>The issue was originally encountered on a WCF Data Service (OData) where a large amount of data was being returned (~3MB) and the application consuming the data (an MVC website) would sporadically hang on some of the requests and would eventually time out.</p> <p>The issue could be replicated on smaller data payloads but would take a long time to occur. The issue has been replicated on both Cassini and IIS 7. When running through IIS I could see the hung W3 worker process stuck in the 'SendResponse' state until it times out.</p> <p>To narrow down the cause of the issue I created a console app that would sequentially download content from an ASP.NET site. The issue was replicated on a WCF Data Service (OData), a standard WCF Service, and a Web Forms page that output similar data directly to the HttpResponse object. The example code used is using the standard WCF Service as an example (for ease of setup for those trying to replicate it).</p> <p>Console App Client:</p> <pre><code> static void Main(string[] args) { Console.ReadKey(); // press any key to start test do { var req = WebRequest.Create(new Uri("http://localhost:26332/WCFTest.svc/GetData")); var response = req.GetResponse(); using (var stream = response.GetResponseStream()) { var content = new StreamReader(stream).ReadToEnd(); } } while (true); } </code></pre> <p>WCF Service:</p> <pre><code> public class Service1 : IService1 { public TestClass[] GetData() { return Enumerable .Range(0, 15000) .Select(i =&gt; new TestClass{ ID = "1" }) .ToArray(); } } [DataContract] public class TestClass { [DataMember] public string ID { get; set; } } [ServiceContract] public interface IService1 { [OperationContract] [WebGet(UriTemplate = "GetData")] TestClass[] GetData(); } </code></pre> <p>After a number of calls (this differs on each run, but is usually less than 30) to the web service the GetResponseStream call will hang.</p> <p>Any ideas on what could be going wrong or how to narrow down the cause of the issue would be appreciated!</p> <p>Service web.config</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;services&gt; &lt;service name="WcfService2.Service1" &gt; &lt;endpoint address="" binding="webHttpBinding" contract="WcfService2.IService1" behaviorConfiguration="webHttp"/&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="webHttp"&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>WCF Data Services code:</p> <pre><code>public class Service1 : DataService&lt;ODataContext&gt; { public static void InitializeService(DataServiceConfiguration configuration) { configuration.SetEntitySetAccessRule("*", EntitySetRights.AllRead); } } public class ODataContext { public IQueryable&lt;TestClass&gt; Test { get { return Enumerable .Range(0, 15000) .Select(i =&gt; new TestClass {ID = "1"}) .AsQueryable(); } } } public class TestClass { public string ID { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload