# Timeout

This policy enables Kuma to set timeouts on the outbound connections depending on the protocol.

# Usage

Specify the proxy to configure with the sources selector, and the outbound connections from the proxy with the destinations selector.

The policy lets you configure timeouts for HTTP, GRPC, and TCP protocols. More about Protocol support in Kuma.

# Configuration

Timeouts applied when communicating with services of any protocol:

Field: connectTimeout
Description: time to establish a connection
Default value: 10s
Envoy conf: Cluster (opens new window)

Timeouts applied when communicating with TCP services:

Field: tcp.idleTimeout
Description: period in which there are no bytes sent or received on either the upstream or downstream connection
Default value: disabled
Envoy conf: TCPProxy (opens new window)

Timeouts applied when communicating with HTTP, HTTP2 or GRPC services:

Field: http.requestTimeout
Description: is a span between the point at which the entire downstream request (i.e. end-of-stream) has been processed and when the upstream response has been completely processed
Default value: disabled
Envoy conf: Route (opens new window)

Field: http.idleTimeout
Description: time at which a downstream or upstream connection will be terminated if there are no active streams
Default value: disabled
Envoy conf: HTTPConnectionManager and Cluster (opens new window)

Field: http.streamIdleTimeout
Description: amount of time that the connection manager will allow a stream to exist with no upstream or downstream activity
Default value: disabled
Envoy conf: HTTPConnectionManager (opens new window)

Field: http.maxStreamDuration
Description: maximum time that a stream’s lifetime will span
Default value: disabled
Envoy conf: Cluster (opens new window)

# Default general-purpose Timeout policy

By default, Kuma creates the following Timeout policy:

    Default timeout policy works fine in most cases. But if your application is using GRPC streaming (opens new window) make sure to set http.requestTimeout to 0s.

    # Matching

    Timeout is an Outbound Connection Policy. The only supported value for destinations.match is kuma.io/service.

    # Builtin Gateway support

    Timeouts are connection policies and are supported by configuring the timeout parameters on the target Envoy cluster. Request timeouts are configured on the Envoy routes and may select a different Timeout policy when a route backend forwards to more than one distinct service.

    Mesh configures an idle timeout on the HTTPConnectionManager, but doesn’t consistently use the Timeout policy values for this, so the semantica are ambiguous. There’s no policy that configures the idle timeout for downstream connections to the Gateway.

    # Inbound timeouts

    Currently, there is no policy to set inbound timeouts. Timeouts on the inbound side have constant values:

    connectTimeout: 10s 
      idleTimeout: 2h
      requestTimeout: 0s
      idleTimeout: 2h
      streamIdleTimeout: 1h
      maxStreamDuration: 0s

    If you still need to change inbound timeouts you can use a ProxyTemplate:

      It's not recommended disabling streamIdleTimeouts and idleTimeout since it has a high likelihood of yielding connection leaks.

      Last Updated: 8/22/2022, 3:23:49 PM