pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.54k stars 772 forks source link

How to detect rtsp server is disconnect phyiscally from network? #957

Closed lchy12345 closed 2 years ago

lchy12345 commented 2 years ago

Hi pedro,

I am using RtspDisplay and DisplayService to stream rtsp to server (aler9/rtsp-simple-server - Docker Hub). How can I know if the device that run the server program is physically disconnect from my app? If I just close the server program from the device, it can be detected by on DisconnectRtp() under DisplayService. But if I remove the LAN line from the device that run the server program, it cannot be detected. Do you have any idea how can I detect this? Thank you very much

pedroSG94 commented 2 years ago

Solved in the last commit: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/716b49f7856a5c76e7b8bd80dc3a64d1b81fbbd5 Compile the last app example to check it and add this line before start stream:

rtspDisplay.setCheckServerAlive(true);

This is optional because I'm using Echo protocol to check it and could be blocked by firewall or not implemented in server side. In order to avoid problems with implementations of other users it is disabled by default because a disconnection of this type is not a common case. If all is working fine I will upload a release

AlexUrrutia commented 2 years ago

Hello Pedro, will this work on RTMP too? I’m using nginx

pedroSG94 commented 2 years ago

Yes, it was added to rtsp and rtmp: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt#L230 https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtsp/src/main/java/com/pedro/rtsp/rtsp/RtspClient.kt#L323 Test it and let me know if it is working in your case

lchy12345 commented 2 years ago

Thanks so much. It works well for me.