问题
I have a somewhat long-taking WCF-based process. WCF service runs in Azure if its of any help. The issue I believe has to do with timeouts:
1) Winforms client has the following .config setting in the binding section:
<wsHttpBinding>
<binding name="XXX" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="255" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
2) WCF service has the following binding section in the web.config
<wsHttpBinding>
<binding name="XXX" maxReceivedMessageSize="10000000" sendTimeout="00:10:00" receiveTimeout="00:10:00" closeTimeout="00:10:00" openTimeout="00:10:00">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
<readerQuotas maxArrayLength="2000000" maxBytesPerRead="10000000" maxStringContentLength="10000000" maxDepth="255" />
</binding>
</wsHttpBinding>
3) I have one long-running method in WCF (generally 2 minutes). Clients call the method, and those that execute for longer then 1 minute are getting thrown out with an exception. This is the most inner exception:
<InnerException>
<Type>System.Net.Sockets.SocketException</Type>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
<Frame>at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</Frame>
</StackTrace>
</InnerException>
</InnerException>
4) The WCF call itself completed successfully, however (I have both Start/End logged on server side). How do I avoid the exception?
Thank you!
回答1:
The Windows Azure load balancer terminates idle connections after 60 seconds.
回答2:
Check out the latest post from Azure team... http://azure.microsoft.com/blog/2014/08/14/new-configurable-idle-timeout-for-azure-load-balancer/
回答3:
Updated answer:
Azure load balancer terminates idle connections after 4 minutes. If you're interested in increasing/decreasing timeout value, check this article:
https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/
来源:https://stackoverflow.com/questions/4858800/wcf-timeout-issue