Open daxiachonger opened 3 months ago
In nginx-rtmp module there is on_publish_done
directive using which you can specify the URL at which the HTTP POST request will be sent once the stream is terminated.
rtmp {
server {
listen 1936 proxy_protocol;
application live {
live on;
record off;
push rtmp://localhost:2935;
on_publish_done htp://some_valid/url;
}
}
}
This way you can setup the server (with the adequate rest api) that will interrupt the stream source (the one connected at port 1935) once it receives the request from the on_publish_done
directive. The interrupted stream name will be stored under the name
key in the form of url encoded arguments.
More info can be found at: https://github.com/JIEgOKOJI/nginx-rtmp/blob/master/directives.md#on_publish_done
@SaltyPretzel303 Thanks for the response. Unfortunately, the client sends the stream to port 1935, which we cannot interrupt. Is there no way to achieve this using the RTMP directive? I have tried using the HTTP Control module to disconnect, but it doesn't seem to work. Do you know of a way to achieve this by refactoring the code?
I have never used nginx tcp load balancing directive but from the quick look at the documentation (https://docs.nginx.com/nginx/admin-guide/load-balancer/dynamic-configuration-api/) it seems that the only way may be to remove and then add the rtmp server handling the connection once the on_publish_done
is triggered (inside the POST request sent by the on_publish_done you can get the server's ip). This would of course work if one rtmp server is expected to handle only one incoming rtmp stream.
If that doesn't help check out haproxy tcp load balancer, it is free and has a bit better api for server management.
Is there a way to disconnect a stream connection if the relay disconnects? The following is a code snippet. If the push to port 2935 disconnects, I would like to disconnect the stream to port 1935.