wait_key
The wait_key directive in the NGINX RTMP module is used to specify the waiting time for clients to establish a connection before streaming starts.
Description
The wait_key directive controls the behavior of client connections in streaming applications managed by the NGINX RTMP module. When a stream starts, this directive allows the server to hold off on sending the stream data until a specified timeout occurs, which can help ensure that all intended clients are connected before broadcasting.
This directive accepts a single argument indicating the number of milliseconds to wait. If the directive is set, the server will delay sending the stream to allow clients enough time to connect, which is particularly useful in scenarios where multiple viewers are expected to join at once. It prevents scenarios where viewers join midway through a stream and potentially miss important content. This is particularly beneficial in live streaming situations where synchrony among viewers enhances the viewing experience.
The directive can only be used within the RTMP application block and has direct implications on the user experience during broadcast events. It ensures that all clients are synchronized before the stream begins, but setting it to a high value could cause viewers to wait longer than necessary, potentially decreasing engagement if they are left waiting for an extended period.
Config Example
application live {
live on;
wait_key 5000;
}Setting wait_key to a high value may lead to viewer dissatisfaction if they are delayed from accessing the stream interface.
If no clients connect within the wait time, the stream will start anyway, which may lead to missed content for latecomers.