push_reconnect

The push_reconnect directive configures the automatic reconnection behavior for live stream push clients in the NGINX RTMP module.

Syntaxpush_reconnect time_in_seconds;
Defaultnone
Context
Arguments1

Description

The push_reconnect directive is a configuration option in the NGINX RTMP module that allows you to define how the server should handle reconnections from a push client when a connection is lost. When streaming live content, maintaining a consistent connection is crucial. If a push client loses connection due to network issues or server downtimes, this directive enables the server to attempt to automatically reconnect after the specified interval instead of terminating the connection immediately. This feature is particularly useful for live streaming scenarios, ensuring that interruptions in connectivity do not result in dropped streams and providing a smoother experience for viewers.

Parameters consist of a single argument which specifies the time interval, in seconds, for the reconnection attempts. For instance, setting push_reconnect 5; would make the server wait five seconds before trying to re-establish the connection with the push client. The directive should be set in relevant application context to be effective. Additionally, it is important to note that if the client does not recover within the time frame defined, it may lead to potential stream drops, so proper tuning is necessary depending on the expected network reliability.

Config Example

application live {
    live on;
    push rtmp://backup_server/live;
    push_reconnect 5;
}

Ensure the correct unit (seconds) is applied; specifying an incorrect format will result in configuration errors.

Setting a too-short reconnect interval may overload the server with reconnection attempts in unstable network conditions.

Ensure that any dependent directives that affect stream behavior (like push) are properly configured alongside push_reconnect.

← Back to all directives