Frage

We noticed that our application which uses netTcpBinding suddenly stopped working. After examining the event log on the server which hosts the service, I found the following warning (one of series of many):

Exception information: Exception type: TimeoutException Exception message: The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.

Server stack trace: at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

To fix the issue, I had to increase the size of maxReceivedMessageSize by 10, so my new binding looks like this:

>  <netTcpBinding>
>     <binding name="largeBufferNetTcpBinding" listenBacklog="100" maxBufferSize="519730000" maxConnections="100"
>              maxReceivedMessageSize="519730000" portSharingEnabled="true">
>       <readerQuotas maxArrayLength="519730000"/>
>       <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
>       <security>
>         <message clientCredentialType="Windows"/>
>       </security>
>     </binding>
>     <binding name="defaultNetTcpBinding" portSharingEnabled="true"/>
>     <binding name="defaultNetTcpMexBinding" portSharingEnabled="true">
>       <security mode="None"/>
>     </binding>      </netTcpBinding>

I don't understand how the maxReceivedMessageSize is related to the TimeoutException shown above. What can I do to troubleshoot this further and make the service more reliable?

War es hilfreich?

Lösung

Hard to tell exactly what's going on in your client/service interaction based on the info in your question but here are some things to try:

First, change everything that you set to 519730000 back to the default values except maxReceivedMessageSize which should be set to something in the range of 2 - 3 MB (start at 2097152 & increase until that message size exception goes away).

If that doesn't work, keep the same settings I've suggested but change the config to basicHttpBinding instead of netTcpBinding in both the service and client for this test. If this binding change works then it's very likely you're not properly disposing of the WCF client instances (ClientBase or channels from ChannelFactory). netTcpBinding depends on sessions and if the client instances aren't disposed of correctly, your code isn't releasing TCP resources efficiently on both the service & client. BTW: wrapping the client instance in using is not the right way either because of the funkiness of the WCF Dispose implementation.

If the calls still have timeouts, then you've pretty much eliminated bad TCP & client configuration and you should focus on the code performance of the service implementation.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top