nchan_subscriber_timeout

The nchan_subscriber_timeout directive sets the maximum amount of time a subscriber can remain idle before the server closes the connection.

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

Description

The nchan_subscriber_timeout directive is used to specify the timeout duration for subscriber connections in the Nchan module. This directive helps manage resources by enforcing a limit on how long the server will wait for activity from a subscriber. If a subscriber remains idle for longer than the specified timeout, Nginx will automatically close the connection, which can help prevent resource exhaustion from too many idle connections.

This directive can be set in various Nginx contexts such as http, server, location, and if in location, allowing for flexible configurations depending on the specific needs of different endpoints. The value for nchan_subscriber_timeout must be specified in a time format, such as seconds (s), minutes (m), or hours (h). When configured appropriately, this directive not only optimizes the efficiency of message delivery to active subscribers but also enhances the overall stability and performance of the server by managing connected clients effectively.

Using this directive correctly is critical in high-load scenarios where many subscribers may be connected intermittently. By configuring an appropriate timeout, system administrators can ensure that resources are adequately allocated and that slowness or bottlenecks are minimized during high traffic periods. By default, there is no timeout set, which means that subscriber connections can remain open indefinitely unless otherwise specified. This could potentially lead to issues in environments with variable subscriber activity.

Config Example

http {
    nchan_subscriber_timeout 30s;

    server {
        location /subscribe {
            nchan_subscriber;
        }
    }
}

Make sure to specify the time format correctly; incorrect formats may lead to configuration errors.

A lack of a timeout may lead to resource exhaustion in high traffic scenarios.

← Back to all directives