Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF: StreamedResponse throws Timeout after a few processed calls
    text
    copied!<p>i'm trying to set up an WCF-Web that returns data from the database as Streamed Response to the Client. The method returns 45.000 Items currently. </p> <p>My problem is, that when i try to call this method a couple of times, some requests will succeed, while the next call dies with an TimeoutException - seems like the client is not able to establish a new connecton to the host. If i change the TransferMode to "Buffered" it will work like intended.</p> <p>The amount of successfully processed calls can be increased by increasing the System.Net.ServicePointManager.DefaultConnectionLimit to a larger Number. </p> <p>It seems to me, that the client does not close the connection? But why only in StreamedResponse mode? Where's the mistake? Any idea? </p> <p>Source:</p> <pre><code>public static void DoCall() { var factory = new ChannelFactory&lt;ICacheService&gt;("ICacheService", new EndpointAddress(...)); ICacheService service = factory.CreateChannel(); try { var itemsMessage = service.DoStreaming( Message.CreateMessage(MessageVersion.Soap11, "DoStreaming", "SomeArgumnt") ); foreach (Item item in GetAllItems(itemsMessage)) { ... } var serviceChannel = ((IServiceChannel) service); if (serviceChannel.State != System.ServiceModel.CommunicationState.Faulted) serviceChannel.Close(); itemsMessage.Close(); ((IServiceChannel)service).Close(); } catch (Exception ex) { ((IServiceChannel) service).Abort(); } factory.Close(); } private static IEnumerable&lt;Item&gt; GetAllItems(System.ServiceModel.Channels.Message message) { XmlReader reader = message.GetReaderAtBodyContents(); if (reader.LocalName != "results") { throw new Exception("The service returned an invalid message"); } XmlSerializer serializer = new XmlSerializer(typeof(Item)); reader.ReadStartElement("results"); while (!reader.EOF &amp;&amp; reader.LocalName == "Item") { yield return (Item)serializer.Deserialize(reader); } reader.ReadEndElement(); } </code></pre> <p>Client-Binding:</p> <pre><code>&lt;binding name="BasicHttpBinding_ICacheService" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:10:00" maxReceivedMessageSize="1000000000" transferMode="Buffered" &gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;security mode="None"&gt; &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt; &lt;/security&gt; &lt;/binding&gt; </code></pre>
 

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