push_stream_timeout_with_body
The `push_stream_timeout_with_body` directive controls the timeout period for push stream connections that include a body in the response.
Description
The push_stream_timeout_with_body directive is an important configuration setting in the NGINX Push Stream Module that determines how long the server will wait for a subscriber connection to be active when the response includes a body. This directive is particularly relevant for long-lived connections, such as those used with EventSource or WebSockets, where the server continuously sends data to the client. By specifying a timeout duration, the server can close inactive connections and free up resources, ensuring efficient handling of active subscriber connections.
The directive accepts a single argument that specifies the timeout period, which is defined in seconds. If the timeout is reached while waiting for data to be sent to the client, the server will terminate the connection. This is crucial for maintaining performance and responsiveness in scenarios with numerous concurrent subscribers, as it prevents dead connections from consuming server resources indefinitely. Administrators can adjust this timeout value based on their application's specific needs, such as user interaction patterns or data refresh rates.
To implement this directive, it must be placed within the HTTP context of the NGINX configuration. This allows it to affect all relevant push stream connections managed by NGINX. The flexibility provided by this configuration option gives server administrators the power to balance resource usage with client experience effectively.
Config Example
http {
push_stream_timeout_with_body 30s;
}Setting a timeout that is too short may lead to premature connection termination, particularly in high-latency situations.
If no body is sent, the timeout may not be applicable, which could lead to confusion if testing behavior with different response types.