nchan_message_timeout

Sets the timeout duration for messages in the Nchan pub/sub server.

Syntaxnchan_message_timeout time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The nchan_message_timeout directive specifies the duration that a published message remains available for subscribers in the Nchan pub/sub server context. This timeout is critical for ensuring that subscribers can retrieve messages quickly enough, while also preventing staleness in messages within the message bus system. If a message is not consumed within the specified timeout period, it will be removed from the message buffer to free up resources for newer messages.

When configuring this directive, you can set the timeout to any duration such as seconds, minutes, or hours (e.g., 30s, 2m). This flexibility allows fine-tuning based on application needs and expected consumption patterns. When Nchan queues messages, it will check against this timeout to determine whether a message can still be delivered to subscribers or should be discarded. A short timeout may increase message turnover, while a longer timeout may be suitable for scenarios with intermittent connectivity or slower consumers.

It is important to note that this directive is applicable at various levels (http, server, location), which allows for different timeout settings depending on the context within your configuration. However, if set at multiple levels, the most specific configuration takes precedence. Understanding the performance implications and usage patterns of your application is key to setting this timeout correctly.

Config Example

location /channel {
    nchan_subscriber;  # Enable subscriber configuration
    nchan_message_timeout 30s;  # Messages available for 30 seconds
}

Setting the timeout too short may result in loss of messages that subscribers are unable to consume in time.

It is essential to set the value appropriate to the expected load and speed of subscribers to avoid unnecessary message removal.

← Back to all directives