views:

49

answers:

1

I am attempting to transfer around 7000-8000 objects that are not large (only 9 properties per object instance). Does anyone know why when I begin to retrieve more than 5000 or so objects that I get connection errors? It works perfectly until I hit some threshold for data size.

I am exposing the retrieval of these objects via WCF's TCP 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 am calling the service using a ChannelFactory with the following sample code:

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

BindingConfig object is a NetTcpBinding property in my code that is populated as 'new NetTcpBinding("NetTcpBindingConfig")'. My client binding is the exact same as my WCF TCP service binding.

Can anyone offer any insight as to how I can retrieve all of the data (it seems my maximum limit is ~5000 objects with my current setup)? Any help is much appreciated. Thanks.

EDIT: In case anyone runs into this, see the accepted solution about the MaxItemsInObjectGraph. If, however, you are using ChannelFactory from the Client to consume your services, see the following code to make it work:

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

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

Consider increasing MaxItemsInObjectGraph quota as well (its default value is 64k). It should be on both the server and the client side. See the sample configuration:

alt text

bsnote
You sir are a genius. This is exactly what I had to do. Since I am using the ChannelFactory, see my updated posted to find out what I did to rectify this on the Client side.
Brandon