* Adding a different location to get channels statistics *push_stream_channels_statistics*
* Adding new directives "push_stream_max_number_of_channels":#push_stream_max_number_of_channels, "push_stream_max_number_of_broadcast_channels":#push_stream_max_number_of_broadcast_channels and "push_stream_memory_cleanup_timeout":#push_stream_memory_cleanup_timeout
* Removed support to PUT and DELETE http methods on publisher location
* Removed different types of return on publishing messages in case that was published on a empty channel or on one which has subscribers
* Removed directive push_stream_subscriber_disconnect_interval, this interval is calculate based on push_stream_subscriber_connection_timeout
A string representing a set of channels id and backtrack desired messages separated by slash, example _/channel1.b3/channel2.b5/channel3.b2_.
The backtrack means the amount of old messages from each of the channels that will be delivered to the subscriber. On the example will be 3 messages from channel1, 5 from channel2 and 2 from channel3.
Backtrack isn't needed, you can only sign channels without get old messages, or you can mix things.
More accepted examples: _/channel1_, _/channel1/channel2_, _/channel1.b5/channel2_, _/channel1/channel2.b6_, ...
Must be present on location of the push_stream_subscriber.
<pre>
<code>
location /sub/(.*) {
set $push_stream_channels_path $1;
}
#channels path is now part of url
#(/sub/channel_id_string or /sub/channel_id_string.b2/other_channel)
|"push_stream_max_channel_id_length":#push_stream_max_channel_id_length |unset|number|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
|"push_stream_broadcast_channel_prefix":#push_stream_broadcast_channel_prefix |unset|any string|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
|"push_stream_message_template":#push_stream_message_template |unset|any string|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
|"push_stream_max_number_of_channels":#push_stream_max_number_of_channels |unset|number|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
|"push_stream_max_number_of_broadcast_channels":#push_stream_max_number_of_broadcast_channels |unset|number|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
|"push_stream_memory_cleanup_timeout":#push_stream_memory_cleanup_timeout |30 seconds|time constant|http, location|(push_stream_subscriber and push_stream_publisher) or main nginx configuration|
Defines a location as a source of statistics. You can use this location to get statistics about a specific channel, or about all channels, in a resumed ou summarized way.
To get statistics about all channels in a summarized way you have to make a GET in this location without specify a name in the "push_stream_channel_id":#push_stream_channel_id variable .
To get statistics about all channels in a detailed way you have to specify "ALL" in the "push_stream_channel_id":#push_stream_channel_id variable .
To get statistics about a channel you have to specify the name in the "push_stream_channel_id":#push_stream_channel_id variable .
You can get statistics in the formats plain, xml, yaml and json. The default is json, to change this behavior you can use *Accept* header parameter passing values like "text/plain", "application/xml", "application/yaml" and "application/json" respectivelly.
<pre>
<code>
location /channels_stats {
push_stream_channels_statistics;
set $push_stream_channel_id $arg_id;
}
# /channels_stats -> get statistics about all channels in a summarized way
# /channels_stats?id=ALL -> get statistics about all channels in a detailed way
# /channels_stats?id=channel_id -> get statistics about a channel
</code>
</pre>
h4(#push_stream_publisher). push_stream_publisher
context: location
Defines a location as a message publisher. Requests to a publisher location are treated as messages to be sent to subscribers.
This location supports two http methods:
GET, make possible to get statistics about the channel
POST, publish a message to the channel
<pre>
<code>
location /pub {
push_stream_publisher;
set $push_stream_channel_id $arg_id;
}
# GET /pub?id=channel_id -> get statistics about a channel
# POST /pub?id=channel_id -> publish a message to the channel
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The text template that will be used to format the message before be sended to subscribers. The template can contain any number of the reserved words: ==~id~, ~text~ and ~channel~, example: "<script>p(~id~,'~channel~','~text~');</script>"==
The content type used on responses to subscribers. Must be complient with "push_stream_header_template":#push_stream_header_template and "push_stream_message_template":#push_stream_message_template.
h4(#push_stream_ping_message_interval). push_stream_ping_message_interval [ time ]
default: -
context: location
location: push_stream_subscriber
The time interval in which a keepalive message is sent to subscribers.
The size of the memory chunk this module will use to store published messages, channels and other shared structures.
When this memory is full any new request for publish a message or subscribe a channel will receive an 500 Internal Server Error response.
h4(#push_stream_store_messages). push_stream_store_messages [ on | off ]
default: off
context: location
location: push_stream_publisher
Whether or not message queuing is enabled.
If store messages is "On" is needed to set at least one of these two directives "push_stream_min_message_buffer_timeout":#push_stream_min_message_buffer_timeout or "push_stream_max_message_buffer_length":#push_stream_max_message_buffer_length.
h4(#push_stream_min_message_buffer_timeout). push_stream_min_message_buffer_timeout [ time ]
default: -
context: location
location: push_stream_publisher
The length of time a message may be queued before it is considered expired. If you do not want messages to expire, just not set this directive.
h4(#push_stream_max_message_buffer_length). push_stream_max_message_buffer_length [ number ]
default: -
context: location
location: push_stream_publisher
The maximum number of messages to store per channel. A channel's message buffer will retain at most this many most recent messages. If you do not want messages to be discarded by length, just not set this directive.
h3. Security
h4(#push_stream_authorized_channels_only). push_stream_authorized_channels_only [ on | off ]
default: off
context: location
location: push_stream_subscriber
Whether or not a subscriber may create a channel by making a request to a push_stream_subscriber location. If set to on, a publisher must send a POST request before a subscriber can request messages on the channel. Otherwise, all subscriber requests to nonexistent channels will get a 403 Forbidden response.
This restriction is not applied to broadcast channels, but to subscribe to a broadcast channel is necessary to subscribe at least to one normal channel, and if this directive is set to on this channel has to be created before.
h4(#push_stream_subscriber_connection_timeout). push_stream_subscriber_connection_timeout [ time ]
default: -
context: location
location: push_stream_subscriber
The length of time a subscriber will stay connected before it is considered expired and disconnected. If you do not want subscribers to be automatically disconnected, just not set this directive.
But, this operation is very important to help Nginx recycle memory consumed to send messages to susbscriber, allocated at pool request.
h4(#push_stream_max_channel_id_length). push_stream_max_channel_id_length [ number ]
default: -
context: location
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
Maximum permissible channel id length (number of characters). Longer ids will receive an 400 Bad Request response.
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The string prefix used to identify when a channel is as normal or broadcast channel, example: when you set this directive as "bd_", "bd_ch1" will be a broadcast channel
h4(#push_stream_broadcast_channel_max_qtd). push_stream_broadcast_channel_max_qtd [ number ]
default: -
context: location
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The maximum number of broadcast channels that a subscriber may sign on the request.
This directive works in conjunction with "push_stream_authorized_channels_only":#push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent broadcast channels.
h4(#push_stream_max_number_of_channels). push_stream_max_number_of_channels [ number ]
default: -
context: location
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The maximum number of concurrent channels on the server. If you do not want to limit the number of channels, just not set this directive.
h4(#push_stream_max_number_of_broadcast_channels). push_stream_max_number_of_broadcast_channels [ number ]
default: -
context: location
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The maximum number of concurrent broadcats channels on the server. If you do not want to limit the number of broadcast channels, just not set this directive.
h4(#push_stream_memory_cleanup_timeout). push_stream_memory_cleanup_timeout [ time ]
default: 30 seconds
context: location
location: (push_stream_subscriber and push_stream_publisher) or main nginx configuration
The length of time a message or a channel will stay on garbage collection area before it is completly discarded, freeing the shared memory. The minimum length is 30 seconds to ensure that no one is using these elements.
This operation is very important to help Nginx recycle memory consumed to create messages and channels, so do not use a large time.
h2(#attention). Attention
This module controls everything needed to send the messages to subscribers.
So is strongly recommended to you disable Nginx's chuncked filter to reduce memory consumption.
You can do this using the _chunked_transfer_encoding_ directive on subscriber location
<pre>
<code>
# solving some leakage problem with persistent connections in