I'm implementing WCF netTCPBinding and encountering a problem while running tasks related to the database. The exception is "System.Net.Sockets.SocketException: 'An existing connection was forcibly closed by the remote host' in net tcp binding". However, the behaviour is unpredictable sometimes it gives no exception and runs smoothly and sometimes it gives an exception.
I added service throttling, assigned maximum values to reader quota and buffer size but nothing worked for me. However, I unable to increase max connection value from 10 to other value because it gives an exception. I tried everything but nothing is working.
web.config
<netTcpBinding>
<binding name="IOperationsCenterService_server_TCP" closeTimeout="01:03:00" openTimeout="01:03:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false" />
<security mode="None">
<!--<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />-->
</security>
</binding>
</netTcpBinding>
<behaviors>
<serviceBehaviors>
<behavior name="OpsCenter.ServiceApp.OperationsCenterServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="10000"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<service behaviorConfiguration="OpsCenter.ServiceApp.OperationsCenterServiceBehavior" name="OpsCenter.ServiceApp.OperationsCenterService">
<identity>
<dns value="localhost" />
</identity>
<endpoint address="" binding="netTcpBinding" contract="OpsCenter.ServiceApp.IOperationsCenterService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
App.config
<netTcpBinding>
<binding name="WSHttpBinding_IOperationsCenterService" closeTimeout="01:03:00" openTimeout="01:03:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false"/>
<security mode="None">
</security>
</binding>
</netTcpBinding>
Please help I'm stuck here since Monday.
Note 1: The application runs perfectly well in visual studio debug mode. However, the problem occurred in release mode or when I installed an application on the client machine.