none
WCF Server side timeout

    Question

  •                 I’d like to set the WCF server side timeout value so that if client dies before closing the proxy due to some reason server can free up the connection. Is this done in same way as client in <binding> section of web.config? Which ones (closeTimeout, openTimeout, receiveTimeout, sendTimeout) are relevant for server side, if we are using basicHttpBinding.? Are there any additional timeout settings? How can I change these values using an API? We use .NET 3.51 currently and will be migrating to .NET 4 soon. We are hosting the WCF service in IIS 7.0.

    Thanks.

     

    Friday, July 9, 2010 5:23 PM

Answers

  • Hi, 

    What you mean by free up the connection? As soon as you close your proxy you will free up a connection, and if you are having problems having enough connection for serving your clients you can configure your throttling options, for example modifying the value for max concurrent sessions, or connections on server side.

    Besides, you can configure your service to work as percall and not as per session so you can be sure that no session would be maintaned between your proxy open method and your proxy close method.

    Hope this helps


    Luis Diego Rojas. http://icomparable.blogspot.com
    MCP, MCTS Biztalk Server
    Saturday, July 10, 2010 1:16 AM
  • Hello,

    what value would you like to set on server side? I made some tests because this topic interests me and here is my conclusion (but I can be wrong).

    BasicHttpBinding does not use any kind of session so there should not be any relation to setting of receiveTimeout which is normally used to control connection timeout but:

    BasicHttpBinding uses HTTP persistent connection. Persistance is provided by Connection: Keep-Alive HTTP header which allows sharing single TCP connection for many HTTP requests/responses. I didn't find the termination timeout for HTTP persistent connection so I measured the timeout in Process monitor. The timeout was always 100s of inactivity. I have no idea how to change this timeout. I tryed to reconfigure IIS's keep-alive timeout but it doesn't work (default value is 120s).

    The interesting thing is that closing proxy/channel on the client side does not close the TCP connection. The connection is still opened and prepared to be used by another proxy to the same service. The connection closes when 100s inactivity timeout expires or when application is terminated. Btw. there is RFC which defines that max. two such TCP connections can exists between client and single server (this is default behavior in windows but can be changed).

    You can turn off HTTP persistent connection if you implement cutomBinding and set keepAliveEnabled="false" in httpTransport element. This will force client to create new TCP connection for each HTTP request.

    Best regards,
    Ladislav

    Sunday, July 11, 2010 10:52 AM

All replies

  • Hi, 

    What you mean by free up the connection? As soon as you close your proxy you will free up a connection, and if you are having problems having enough connection for serving your clients you can configure your throttling options, for example modifying the value for max concurrent sessions, or connections on server side.

    Besides, you can configure your service to work as percall and not as per session so you can be sure that no session would be maintaned between your proxy open method and your proxy close method.

    Hope this helps


    Luis Diego Rojas. http://icomparable.blogspot.com
    MCP, MCTS Biztalk Server
    Saturday, July 10, 2010 1:16 AM
  • Hello,

    what value would you like to set on server side? I made some tests because this topic interests me and here is my conclusion (but I can be wrong).

    BasicHttpBinding does not use any kind of session so there should not be any relation to setting of receiveTimeout which is normally used to control connection timeout but:

    BasicHttpBinding uses HTTP persistent connection. Persistance is provided by Connection: Keep-Alive HTTP header which allows sharing single TCP connection for many HTTP requests/responses. I didn't find the termination timeout for HTTP persistent connection so I measured the timeout in Process monitor. The timeout was always 100s of inactivity. I have no idea how to change this timeout. I tryed to reconfigure IIS's keep-alive timeout but it doesn't work (default value is 120s).

    The interesting thing is that closing proxy/channel on the client side does not close the TCP connection. The connection is still opened and prepared to be used by another proxy to the same service. The connection closes when 100s inactivity timeout expires or when application is terminated. Btw. there is RFC which defines that max. two such TCP connections can exists between client and single server (this is default behavior in windows but can be changed).

    You can turn off HTTP persistent connection if you implement cutomBinding and set keepAliveEnabled="false" in httpTransport element. This will force client to create new TCP connection for each HTTP request.

    Best regards,
    Ladislav

    Sunday, July 11, 2010 10:52 AM

  • I have solved the same problem and created a blog post: http://kanchengcao.blogspot.com/2012/06/adding-timeout-and-congestion.html
    In short, (1) WCF server timeout config do not work (2) you could implement a timeout as others said (3) such timeout do not guarentee timely response to client since the request could be queued for long before entering your code with timeout, so I implemented method to drop requests if the server is overloaded and is expected to cause more timeouts.

    frankcao

    • Proposed as answer by frankcao Saturday, June 16, 2012 1:17 AM
    Saturday, June 16, 2012 1:17 AM