max_message

The `max_message` directive limits the maximum size of messages in NGINX RTMP module.

Syntaxmax_message size_in_bytes;
Defaultnone
Context
Arguments1

Description

The max_message directive in the NGINX RTMP module is designed to set a limit on the size of incoming messages when streaming media. This is crucial for managing the resource consumption of the server and preventing abuse or overload due to excessively large messages. When a message exceeds the specified size, it is simply discarded, and a warning may be logged.

This directive accepts a single argument representing the maximum message size in bytes. If not specified, the default behavior allows messages of any size, which could lead to performance issues or stability concerns if large untrusted inputs are processed. When configuring max_message, administrators should consider the expected types of media streams and adjust the value accordingly to balance performance with necessary functionality.

The proper usage of this directive is critical, especially in live broadcasting scenarios where a sudden spike in message size might occur. Therefore, using max_message helps maintain a more predictable and stable server performance overall. This configuration is particularly important when numerous simultaneous users are connected, ensuring that no single connection starves resources from others.

Config Example

rtmp {
    server {
        application live {
            max_message 1048576;
            live on;
        }
    }
}

Setting max_message too low may cause legitimate messages to be discarded, affecting the streaming experience.

Not configuring max_message when expecting large messages can lead to unpredictable behavior.

← Back to all directives