Ok so I have finally got my WCF service running great. It has taken me some time but I have fixed just about all of my issues. The only issue I am having now is this one.
One of my data requests is fairly large, it contains a collection of about 37k. The error I am getting is as follows.
The socket connection was aborted. This could be caused by an error processing
your message or a receive timeout being exceeded by the remote host, or an
underlying network resource issue. Local socket timeout was '00:00:59.9840000'.
Initially you might be thinking that its a serialization issue or that I need to change my capacity on my binding.
Here is my binding, on the client.
<netTcpBinding>
<binding name="MyCustomBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="1000000000" maxBufferSize="1000000000"
maxConnections="10" maxReceivedMessageSize="1000000000">
<readerQuotas maxDepth="32" maxStringContentLength="1000000000"
maxArrayLength="50000" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
I have changed my binding information to allow a larger capacity; however, that doesn't fix my problem. The only reason I started looking at changing the capacity for maxReceiveMessageSize is because if I throttle the results down to a collection of 1000, I have no problems. Are there any configurations other than binding that I need to worry about when it comes to large communications?
Thanks!
EDIT 1
Also I have changed my timeout to like 00:10:00 on each timeout value in the binding and it didnt seem to make a difference. The response from the server is less than 5 seconds long.
Edit 2
Service config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings />
<client />
<services>
<service behaviorConfiguration="serviceBehavior"
name="MyService">
<clear />
<endpoint address="MyCustomObject" binding="netTcpBinding"
bindingConfiguration="" name="MyCustomObject"
contract="MyService.IContract" >
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/MyService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
EDIT 3
Please understand that I did not include any sensitive information about that service model, so they have been replaced with MyCustom***. Again, please read the question carefully I am successfully transferring data back and forth using this service through other endpoints without a problem. Also, like I said above I can transfer data across that endpoint if I limit the result to 1000.
EDIT 4
Ok let me be more clear. The client application is picking up the correct binding. The reason I know, is because when my application returns a result set of about 4500 results in a collection, gives me the following exception.
The maximum message size quota for incoming messages (65536) has
been exceeded. To increase the quota, use the MaxReceivedMessageSize
property on the appropriate binding element.
So I increase the MaxReceiveMessageSize to the highest possible value, 2147483647. According to this post. After I do that I can safely return my result set. Now here is the kicker, I go up to 5000 results and I get my initial exception at the top of this question.
The socket connection was aborted. This could be caused by an error processing
your message or a receive timeout being exceeded by the remote host, or an
underlying network resource issue. Local socket timeout was '00:00:59.9840000'.
So clearly the application is picking up the correct binding configuration otherwise it wouldn't have responded to my change in MaxReceiveMessageSize. So at this point the real question is why is it failing over such a small change.
FINALLY! Ok so this was the problem. I was exceeding the, MaxItemsInObjectGraph value on the client end. So I needed to add this behavior to the clients configuration file.
Server config
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior" >
<serviceMetadata />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Client Config
<behaviors>
<endpointBehaviors>
<behavior name="endpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
Then on the clients configuration file endpoint, I had to add that behavior.
Client config
<client>
<endpoint address="net.tcp://localhost:8732/RootAddress/EndpointLocation"
binding="netTcpBinding" bindingConfiguration="EndpointLocation"
behaviorConfiguration="endpointBehavior"
contract="ServiceReference1.IInterface" name="Interface">
<identity>
<userPrincipalName value="" />
</identity>
</endpoint>
</client>
Just to note, I had to add the behaviors section entirely to the config on the client side. As it was not generated when I use Add Service Reference. This worked flawlessly afterwards, and I was able to retrieve my 37k custom object collection.