Skip to main content

Subgraph timeouts

Although the router comes with good defaults, you can change the timeouts according to your needs. For example, if you need to operate with very slow upstream services, you can increase request_timeout, which defines the maximum amount of time a request can take. Zero means no limit.
  • request_timeout: The maximum amount of time a request can take. The timeout includes connection time, any redirects, and reading the response body.
  • dial_timeout: The maximum amount of time a dial will wait for a connect to complete
  • keep_alive_idle_timeout: The maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
  • keep_alive_probe_interval: Specifies the interval between keep-alive probes for an active network connection.
  • tls_handshake_timeout: Specifies the maximum amount of time waiting to wait for a TLS handshake.
  • response_header_timeout: If non-zero, specifies the amount of time to wait for a server’s response headers after fully writing the request (including its body, if any).
  • expect_continue_timeout: If non-zero, specifies the amount of time to wait for a server’s first response headers after fully writing the request headers if the request has an “Expect: 100-continue” header.

Client timeouts

These timeouts apply to the connections between clients and the router. They protect the router against slow clients, for example clients that open a connection and then send the request headers or body very slowly (slowloris-style attacks), which would otherwise hold connection resources for a long time.
  • request_read_timeout: The maximum amount of time to read the entire client request, including the headers and the body. It starts when the router begins reading the request. Defaults to 60s, the minimum is 1s.
  • request_header_read_timeout: The maximum amount of time to read the client request headers. Use it to drop clients that send headers slowly without shortening the time allowed for large request bodies. Defaults to 0s, which falls back to request_read_timeout. This limit only applies to HTTP/1 connections. For HTTP/2 over TLS, slow headers are limited by idle_timeout instead, except while another stream on the same connection is still open (for example an SSE subscription). To cover that case, an upstream proxy or load balancer must enforce the limit.
  • idle_timeout: The maximum amount of time an idle keep-alive client connection is kept open while waiting for the next request. Defaults to 0s, which falls back to request_read_timeout.
  • write_timeout: The maximum amount of time to write the response to the client, measured from the end of reading the request headers. Defaults to 0s, which disables a timeout.
When the headers are not received in time, the router closes the connection without a response. When the headers were received but the body is not received within request_read_timeout, the router responds with 408 Request Timeout and closes the connection.
write_timeout is disabled by default. Setting it disrupts subscriptions over SSE and multipart: the router closes these long-lived responses once the timeout elapses, even if the subscription is still active, and slow or long-running query responses are cut off the same way. Only set it if your clients don’t use SSE or multipart subscriptions. Subscriptions over WebSockets are not affected; they use engine.websocket_server_write_timeout instead.
The read timeouts don’t affect long-lived responses such as subscriptions over SSE or multipart. To limit how long the router waits for subgraphs, use the subgraph timeouts above.