send_timeout
The `send_timeout` directive sets the timeout for transmitting a response to the client.
Description
The send_timeout directive is used within the NGINX RTMP module to define a maximum amount of time that the server will spend sending data to a client before considering the connection to be timing out. If the time spent sending a response exceeds this limit, the server will close the connection. This is particularly useful in media streaming scenarios, where long-lived connections are common and it is necessary to manage resources efficiently.
This directive accepts a single parameter which specifies the timeout duration. This parameter can be specified in seconds or with a suffix such as 'm' for minutes or 'h' for hours. It's important to note that this timeout is only applied when the connection remains open but the server is not sending any data; if data is being transmitted, the timeout will not be triggered. Appropriate tuning of this value can help avoid problems with client connections in high-latency networks or during periods of inactivity during a stream.
When configuring send_timeout, it is vital to consider the expected behavior of the streaming clients. Too short of a timeout might cut off clients prematurely during long processing times, while a longer timeout could hold server resources longer than necessary, allowing too many connections to aggregate during peak usage. Therefore, it is often advisable to test different values to find an optimal setting for a specific streaming scenario.
Config Example
rtmp {
server {
application live {
live on;
send_timeout 30s;
}
}
}Ensure that the specified timeout value is not too short, as this may cause clients to be disconnected prematurely.
Remember that the send_timeout only applies to unresponsive connections; if data is flowing, this timeout does not activate.
If multiple applications are running with different timeouts, make sure to set the send_timeout in the correct context to avoid confusion.