WCF - Error getting a large list of data (~ 5000 objects)

I am trying to pass about 7000-8000 objects that are not large (a total of 9 properties per instance of the object). Does anyone know why, when I start retrieving more than 5000 or so objects, I get connection errors? It works fine until I click on some threshold for data size.

I am retrieving these objects through the TCP WCF service binding. I have the following sample configuration:

<bindings>
  <netTcpBinding>
    <binding name="NetTcpBindingConfig"
             openTimeout="00:01:00"
             sendTimeout="00:05:00"
             closeTimeout="00:01:00"
             maxBufferPoolSize="2147483647"
             maxBufferSize="2147483647"
             maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647"
                    maxStringContentLength="2147483647"
                    maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
      <security>
        <transport/>
      </security>
    </binding>
  </netTcpBinding>
</bindings>

<services>
  <service behaviorConfiguration="ServiceBehavior"
           name="TestService">
    <endpoint address="" 
              binding="netTcpBinding" 
              bindingConfiguration="NetTcpBindingConfig"
              contract="ServiceInterfaces.ITestService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" 
              binding="mexTcpBinding" 
              contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8526/TestService" />
      </baseAddresses>
    </host>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="Services.ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

From my .NET code, I call the service using ChannelFactory with the following code example:

using (ChannelFactory<ITestervice> channel = new ChannelFactory<ITestService>(BindingConfig, "net.tcp://localhost:8526/TestService"))
{
    ITestService testService = channel.CreateChannel();
    toReturn = testService.LoadAll();
    channel.Close();
}

The BindingConfig object is a NetTcpBinding property in my code that populates like "new NetTcpBinding (" NetTcpBindingConfig "). A client binding is the same as a WCF TCP service binding.

- , (, ~ 5000 )? . .

EDIT: , - , . MaxItemsInObjectGraph. , , ChannelFactory , . , :

foreach (OperationDescription operation in channel.Endpoint.Contract.Operations)
{
    DataContractSerializerOperationBehavior dataContractBehavior = operation.Behaviors[typeof(DataContractSerializerOperationBehavior)] as DataContractSerializerOperationBehavior;

    if (dataContractBehavior != null)
        dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
+3
1

MaxItemsInObjectGraph ( - 64k). , . . :

alt text

+8

Source: https://habr.com/ru/post/1751476/


All Articles