nchan_pub_channel_id

The 'nchan_pub_channel_id' directive specifies the identifier of the publishing channel used in the Nchan module for Pub/Sub applications.

Syntaxnchan_pub_channel_id string | variable;
Defaultnone
Contextserver, location, if in location
Arguments7

Description

The 'nchan_pub_channel_id' directive enables the configuration of the unique identifier for the publishing channel within the Nchan module. This identifier is crucial in ensuring that messages published to the channel are received correctly by subscribers. It supports multiple parameters, allowing for flexible configurations tailored to the application's needs. This directive operates within the context of server, location, and if conditions in the NGINX configuration, allowing for granular control depending on the routing of the requests.

This directive can accept between one to seven arguments, which can be formatted as plain strings or key-value pairs. When the server receives a publish request, nchan_pub_channel_id determines how the request is routed to the appropriate channel. If the parameters provided include references to NGINX variables, Nchan will dynamically resolve these values, making it adaptable to varying conditions and requests. This behavior provides substantial flexibility for developers in designing their Pub/Sub systems, particularly in multi-tenant environments or applications with complex routing logic.

Config Example

location /publish {
    nchan_pub_channel_id my_channel;
    nchan_subscriber_info /subscriber_info;
}

Ensure that the channel ID is unique to prevent message delivery conflicts.

Not using the dynamic variables correctly can lead to unexpected behavior; test with static values first.

If used in a nested context, double-check the defined channel ID for proper routing.

← Back to all directives