timeout
The `timeout` directive in the NGINX RTMP module defines the maximum duration to wait before closing a streaming session due to inactivity.
Description
The timeout directive is utilized to enforce a limit on the duration of a streaming session, making it imperative for maintaining server resources and preventing idle sessions from occupying valuable connections. When a session hits the specified timeout threshold, it prompts the server to terminate the session if no interaction (like streams being published or played) occurs during that period. This directive is particularly useful in scenarios where multiple streams are managed, and administrators want to ensure that inactive streams do not linger indefinitely, thus increasing the efficiency and performance of the server.
The parameter for the timeout directive is a time duration specified in milliseconds and can be set to various values depending on the application's requirements. It operates in the context of live and on-demand streaming, where the idle time is monitored. If the duration defined in the timeout is exceeded, the server will automatically close the stream connection, ensuring that system resources are effectively utilized. Care should be taken when setting this value, as too short a duration can lead to the premature termination of legitimate streaming sessions, while too long may allow inactive sessions to persist, potentially leading to resource exhaustion.
It's important to note that this directive will not affect actively publishing or playing sessions; it specifically monitors inactivity during streaming. As such, administrators should balance their timeout configurations to optimize both resource management and user experience. Furthermore, since this directive is part of the RTMP module, it is specifically tailored for handling real-time streaming processes, making it distinct from other timeout settings available in the broader NGINX configuration.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
timeout 30000; # Set timeout to 30 seconds
}
}
}Excessively short timeout values may disconnect users who are temporarily inactive, leading to a frustrating experience.
Ensure the timeout value is sufficient to accommodate expected user interactions; failure to do so may lead to unexpected disconnections.
The timeout directive only applies to RTMP sessions and does not affect HTTP connections or other NGINX functionalities.