nchan_subscriber_http_raw_stream_separator
The `nchan_subscriber_http_raw_stream_separator` directive sets a custom separator string for raw HTTP streaming responses in the Nchan pub/sub module.
Description
The nchan_subscriber_http_raw_stream_separator directive is used within the Nchan module for defining a specific string that separates messages in raw HTTP streaming responses. This directive is valuable when clients need clear message boundaries, especially in a pub/sub pattern where multiple messages may be sent in a single HTTP response. Using this directive allows developers to specify a desired separator string that is sent between the messages, enhancing the clarity and manageability of the data stream delivered to subscribers.
To employ this directive, you can place it within a server, location, or within an if block in a location context. The argument for this directive should be a valid string that will act as the separator. If you don’t specify one, subscribers that expect a separator may be unable to parse the incoming data correctly. This can lead to issues in applications that require message parsing from an HTTP stream.
The functionality is particularly useful in scenarios where raw HTTP streams are being utilized by subscribers, such as WebSocket connections or EventSource setups, ensuring that the subscriber can differentiate between individual messages using the defined separator. It is important to select a separator that is not likely to be confused with the content of the messages being sent, to avoid parsing errors and data corruption.
Config Example
location /subscribe {
nchan_subscriber_http_raw_stream_separator "\n";
}Ensure that the separator string does not coincide with any data formats you might use in messages to prevent parsing errors.
Using a separator that is too complex may lead to performance issues during string processing on both server and client sides.