so_keepalive
The `so_keepalive` directive enables or disables the TCP keepalive feature for RTMP connections.
Description
The so_keepalive directive is part of the NGINX RTMP module, and it is used to manage the TCP keepalive settings for RTMP (Real-Time Messaging Protocol) connections. When set to 'on', it instructs the NGINX server to enable keepalive packets for open connections, which can help maintain persistent connections by preventing timeout during periods of inactivity. This is particularly useful in streaming applications where keeping the connection open for clients is essential for a smooth streaming experience.
The directive works by adjusting the settings on the underlying TCP sockets to send keepalive packets periodically. This can help detect dead peers and free up resources associated with inactive connections. For operational effectiveness, it is often paired with other directives that manage connection states, making it a critical setting for applications that require high availability and minimal disruption. It’s important to consider the impact of network configurations, as improper use can result in unnecessary network traffic or connection drops if not configured properly.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
so_keepalive on;
}
}
}Enabling keepalive may increase network traffic due to periodic keepalive packets being sent over the network.
Default server settings may override or conflict with this directive, ensure that it is properly configured in the correct context.