Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket connection aborted using NetTcpBinding
    primarykey
    data
    text
    <p>I know there are quite some questions about this issue already, but no reply solved my problem.</p> <p>I have a NetTcpBinding on a server running, and from time to time (not always, like 1 out of 20 to 60 calls, completely random) I receive this exception on the client side:</p> <blockquote> <p>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:01:00'.</p> </blockquote> <p>I noticed that this exceptions occurs much more frequently when the client's connection is slow. </p> <p>Also, the timeout stated is 1 minute, but the exception already occurs after 1 second or so.</p> <p>What I do:</p> <pre><code>var client = GetClient(); client.Open(); bool success = client.Call(); // Exception occurs here (the return value is a bool) </code></pre> <p>I sometimes also get this exception on the server side:</p> <blockquote> <p>A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data.</p> </blockquote> <p>I have server tracing enabled but I get the same exceptions, and it doesn't provide me with any additional insight.</p> <p>My GetClient: </p> <pre><code>NetTcpBinding netTcpBinding = new NetTcpBinding { CloseTimeout = new TimeSpan(0, 0, 30), OpenTimeout = new TimeSpan(0, 0, 30), TransferMode = TransferMode.Buffered, ListenBacklog = 2, MaxConnections = 2, MaxReceivedMessageSize = 10485600, ReaderQuotas = { MaxStringContentLength = 1048576 }, ReliableSession = { Enabled = false }, Security = { Mode = SecurityMode.Transport, Transport = { ClientCredentialType = TcpClientCredentialType.None, ProtectionLevel = ProtectionLevel.EncryptAndSign }, Message = { ClientCredentialType = MessageCredentialType.Windows } } }; </code></pre> <p>Important config from service:</p> <pre><code>&lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="ServiceBehavior"&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpsHelpPageEnabled="true" /&gt; &lt;serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="My.Service.WCF.Tools.CustomAuthorizationManager, My.Service.WCF"&gt; &lt;authorizationPolicies&gt; &lt;clear/&gt; &lt;add policyType="My.Service.WCF.Tools.CustomAuthorizationPolicy, My.Service.WCF" /&gt; &lt;/authorizationPolicies&gt; &lt;/serviceAuthorization&gt; &lt;serviceCredentials&gt; &lt;serviceCertificate findValue="MyService" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /&gt; &lt;/serviceCredentials&gt; &lt;serviceThrottling maxConcurrentCalls="65536" maxConcurrentSessions="65536" maxConcurrentInstances="65536" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;customBinding&gt; &lt;binding name="ServiceBinding" receiveTimeout="00:05:00" maxConnections="65536" listenBacklog="65536"&gt; &lt;transactionFlow /&gt; &lt;sslStreamSecurity requireClientCertificate="false" /&gt; &lt;binaryMessageEncoding /&gt; &lt;tcpTransport transferMode="Buffered" portSharingEnabled="true" maxReceivedMessageSize="1048576" maxPendingConnections="65536" maxPendingAccepts="10"&gt; &lt;connectionPoolSettings leaseTimeout="00:05:00" idleTimeout="00:05:00" maxOutboundConnectionsPerEndpoint="65536" /&gt; &lt;/tcpTransport&gt; &lt;/binding&gt; &lt;binding name="MexBinding" receiveTimeout="00:05:00" maxConnections="65536" listenBacklog="65536"&gt; &lt;tcpTransport transferMode="Buffered" portSharingEnabled="true" maxReceivedMessageSize="1048576" maxPendingConnections="65536" maxPendingAccepts="10"&gt; &lt;connectionPoolSettings leaseTimeout="00:05:00" idleTimeout="00:05:00" maxOutboundConnectionsPerEndpoint="65536" /&gt; &lt;/tcpTransport&gt; &lt;/binding&gt; &lt;/customBinding&gt; &lt;/bindings&gt; </code></pre> <p>I have already updated service reference and tried to change some of the buffer and sizes, but it didn't work (not that I'd expect an issue there as only a bool is returned).</p> <p>Fixed using:</p> <pre><code>OperationContext.Current.OperationCompleted += Test; private void Test(object sender, EventArgs e) { OperationContext.Current.Channel.Close(); } </code></pre> <p>Do not use the Abort but the Close method!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload