1

I am using WCF Services in WPF project. I have a large amount of data, about 847 000 records in table. this exception is throwed on client side

In VM

proxy.ServicesClient client = new proxy.ServicesClient();
var result = client.GetCustomers(); // here throws ('ComunicationException was unhandled by user code: The underlying connection was closed: The connection was closed unexpectedly.')

In App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="BasicHttpBinding_IServices" closeTimeout="00:10:00"
              openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
              maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
            <security mode="None" />
          </binding>
        </basicHttpBinding>
      </bindings>
      <behaviors>
        <endpointBehaviors>
          <behavior name="clientBehavior">
            <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          </behavior>
        </endpointBehaviors>
      </behaviors>
        <client>
            <endpoint address="http://localhost:7902/WpfStoreService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServices"
                contract="proxy.IServices" name="BasicHttpBinding_IServices" behaviorConfiguration="clientBehavior" />
        </client>
    </system.serviceModel>
</configuration>

In Web.Config

<?xml version="1.0"?>
<configuration>

  <connectionStrings>
    <add name="AdventureWorksLTConnectionString" connectionString="Data Source=.;Initial Catalog=AdventureWorksLT;Integrated Security=True;" />
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>    

    <bindings>
      <basicHttpBinding>    
        <binding name="BasicHttpBinding_IServices" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="214748364"
                        maxNameTableCharCount="2147483647"/>

          <security mode="None"/>
        </binding>

      </basicHttpBinding>
    </bindings>

    <services>
      <service name="WpfStore.Services.Services" behaviorConfiguration="debugbehavior">
        <endpoint address="" binding="basicHttpBinding" contract="WpfStore.Services.Contracts.IServices" bindingConfiguration="BasicHttpBinding_IServices"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="debugbehavior">
          <serviceMetadata httpGetEnabled="true"/> 
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>   
  </system.webServer>  
</configuration>

Note: 1. It dose not work with large amount of data. In this case I have about 847 000 records in table. It works with small data perfectly(with about 5000 - 6000 records). 2. I debug it and all record retrieved from SQL server to my DAL; This Exception rises during 5-10 seconds, after I call from client this service function.

west
  • 346
  • 1
  • 5
  • 18
  • 4
    are you seriously sending 847000 records over the wire? maybe you should consider using paging? – failedprogramming Mar 28 '13 at 08:40
  • I simply tested, it did not work 7000 record too – west Mar 28 '13 at 08:55
  • Why don't you trace it. http://stackoverflow.com/q/4271517/413032 Most of these type issues can be solve by tracing. It seems your connection lost. – Davut Gürbüz Mar 28 '13 at 09:42
  • Realistically, how many records are you intending to receive each call? 7000 seems a lot too. – Constanta Mar 28 '13 at 14:07
  • I am sorry for saying this, but you should consider using at least one technique to narrow down the transportation. You can use paging, filtering, or something like it. You have to deal with the limitations of what you are working with. The limit can come from more than just the wcf, can come from IIS, a proxy or something else. – marcelo-ferraz Jun 14 '13 at 18:19
  • @user746499 did you get a solution for this. can you share if so (and if you remember it still :)) – Hari Jul 03 '15 at 07:39

1 Answers1

1

I just added this line in my code

System.Net.ServicePointManager.Expect100Continue = false;

Find the explanation on MSDN

Hope this will help you.

Tassisto
  • 9,877
  • 28
  • 100
  • 157