ping
The 'ping' directive in the NGINX RTMP module is used to monitor the health of the RTMP streaming server by sending periodic signals to connected clients.
Description
The 'ping' directive is an option within the NGINX RTMP module that serves to help maintain the integrity of RTMP stream connections by implementing a periodic pinging mechanism. This directive takes a single argument, which specifies the frequency of the ping signals to be sent to clients. By ensuring that pings are regularly sent, the server can monitor whether clients are still actively connected, enabling it to take preemptive actions if a connection becomes stale or unresponsive. This is particularly important for live streaming applications, where maintaining a stable connection is critical for uninterrupted viewing experiences.
In practice, the specified ping interval determines how often the server sends a ping message to each client. If a client does not respond within a defined timeframe, the server can mark that connection as inactive or closed, thus freeing up resources and maintaining stream quality. The pinging behavior can also help in diagnosing connection issues and improving overall server responsiveness. Additionally, this directive is beneficial when scaling and managing large numbers of simultaneous client connections, as it allows for active monitoring and management of those connections.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
ping 30;
}
}
}Setting a very low ping interval can lead to excessive load on the server and network resources.
If clients are behind firewalls, pings might be blocked, causing false positives for inactive connections.