6

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!

Igorek
  • 15,716
  • 3
  • 54
  • 92
  • Anytime it takes over a minute to run, it returns that error. The error is returned to the client precisely after a minute. The server is still finishing the method call however. – Igorek Feb 01 '11 at 04:50

3 Answers3

8

The Windows Azure load balancer terminates idle connections after 60 seconds.

user94559
  • 59,196
  • 6
  • 103
  • 103
  • 1
    Steve, wow, totally didn't know this... is there anyway to extend the timeout? Some calls may take more then 1 minute to complete! – Igorek Feb 01 '11 at 05:09
  • Interesting. Steve is there any way to modify this behavior, or is the intent for long-running jobs to be farmed out to a worker role with a queue or some other cross-task method? – Taylor Bird Feb 01 '11 at 05:11
  • There's no way at present to change this. However, if you can periodically send data across the TCP connection, it will stay open. (It's only _idle_ connections that get terminated.) – user94559 Feb 01 '11 at 16:57
  • Is there a plan to make this configurable in the future? If there is a plan, any idea when it _may_ be available, eg next release...or not till late next year at best...or it's not on the roadmap at all...just some indication would help :-) – wallismark Sep 19 '11 at 23:50
  • Steve, please, advice if something changed in this area. Or probably it's possible to create some kind of request for the feature to control/increase that timeout? Usually, it's not a problem to keep connection active by calling some dummy method, but for some cases it's just impossible - let say I have 3-rd party service that allow me to send one HTTP POST request and process result (it supports some script language that does not allow to handle connection termination when it's happening), so currently whole process just failing. Hope you will see this message. – Ivan Sokalskiy Nov 13 '11 at 00:49
  • I just encountered this issue with SignalR, would be a nice feature if one could customize the load balancer time-out. –  Nov 30 '11 at 00:23
  • Update to an old thread, as of May 31, 2012, the timeout has been raised above 1 minute. If I remember correctly, its now 4 minutes. – BrentDaCodeMonkey Dec 21 '12 at 17:11
  • Not tried your solution yet, but it gave me a cause to scratch my head again. – Jamshaid K. Feb 09 '20 at 22:01
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/

Mr.RealRM
  • 21
  • 2
0

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/

rahmivolkan
  • 407
  • 2
  • 9