push_subscriber_timeout

The `push_subscriber_timeout` directive sets the maximum allowed idle time for a subscriber connection in NGINX Nchan.

Syntaxpush_subscriber_timeout time;
Defaultnone
Contexthttp, server, location, if in location
Arguments1

Description

The push_subscriber_timeout directive in the NGINX Nchan module is used to specify the maximum duration a subscriber connection can stay idle before being closed. This is particularly important in pub/sub architectures, where active subscriber connections are established to receive messages at real-time. If a subscriber connection does not send any requests within the specified duration, Nginx will automatically terminate that connection to free up resources and manage open connections more efficiently.

The directive accepts a single argument that defines the timeout period. The period can be specified in various time formats such as seconds (s), milliseconds (ms), or minutes (m). Setting the timeout appropriately helps maintain an optimal number of concurrent connections and can reduce the risk of resource exhaustion on the server. Users should consider their application's specific needs—such as how often expect subscriptions to remain active—to configure this directive correctly. If this directive is not set, the default behavior may lead to unwanted disconnections of idle subscribers, depending on how the server is configured.

It is important to also note that this directive can be placed in several contexts, including http, server, location, and inside an if statement in a location block, giving flexibility on how and where it can be applied to control subscriber behaviors in different areas of an NGINX configuration.

Config Example

http {
    nchan_pubsub;
    push_subscriber_timeout 30s;
}

Setting the timeout too low may cause legitimate subscribers to be dropped due to normal fluctuations in network activity.

If the push_subscriber_timeout value is too high, it could result in excessive resource consumption by stale connections.

Make sure to consider the implications on client behavior when adjusting this setting.

This directive is applicable only within a pub/sub context; it has no effect outside these contexts.

← Back to all directives