ping_timeout
The `ping_timeout` directive defines the timeout period for detecting inactive client connections in the NGINX RTMP module.
Description
The ping_timeout directive is crucial in the operation of live streaming applications using the NGINX RTMP module. This directive specifies a timeout period in milliseconds that the server will wait to receive a 'ping' request from a client. If this timeout is exceeded without receiving a ping, the server considers the client to be inactive and may choose to disconnect them. This is particularly important for maintaining server resource efficiency and ensuring that inactive clients do not remain connected indefinitely, which could lead to resource depletion.
When configuring the ping_timeout, the administrator needs to define how long the server should wait before deciding to drop a connection. The value set for ping_timeout should take into account typical network conditions and user behaviors to balance between maintaining connections for legitimate users and freeing resources from inactive ones. A too-short timeout could prematurely disconnect clients that are simply experiencing network latency, while a too-long timeout might unnecessarily allocate resources to inactive clients.
The ping mechanism works in tandem with the server's implementation of RTMP, which often sends periodic pings to the clients to verify their active status. The interaction between ping_timeout and client implementation will dictate the effectiveness of this directive. If the clients are not adhering to the expected ping behavior, the server's settings may require adjustments to optimize performance and user experience.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
ping_timeout 15000;
}
}
}Setting a timeout that is too low can cause legitimate clients to be dropped unexpectedly.
Ensure that client applications are designed to send pings regularly to avoid premature timeout scenarios.