Search code examples
httpkeep-alive

Will client timeout if a request on HTTP persistent connection takes a long time?


If we have a HTTP persistent connection, however one of the request takes a long time (say 30 seconds). Assume client's timeout is 15 seconds.

  1. Is client's reques-timeout respected when used over persistent connection ?

  2. If yes, then does the connection break ?

  3. Is there any way to avoid the entire connection from breaking, and instead just timing out on that one particular request ?


Solution

    1. Client can specify timeout but it depends on the server configuration for using client timeout or its own timeout configuration. By default server side timeout configuration has more priority than client timeout configuration.
    2. No
    3. For having one particular request with different timeout config it's not possible on the same connection But, you can declare different http client config connection and use one of them for default and another one for request that need much more timeout value But they are not in the same keep-alive connection.
      Note, In the client side timeout configuration we have two different type of timeout
      1- Open Connection Timeout 2- Read Response Timeout.
      The first one is declared for open connection between server and client and the second one is declared for how much time client needs to get response for his request.