OpenVidu / openvidu

OpenVidu Platform main repository
https://openvidu.io
Apache License 2.0
1.87k stars 464 forks source link

Openvidu not reconnect to ipcam that restart stream #554

Open dottgonzo opened 3 years ago

dottgonzo commented 3 years ago

Hi,

Thanks for this awesome project. I' working with some app upon openvidu, all are based on rtsp streams as publishers. I've noticed during the development that if I restart the rtsp stream, openvidu loose that stream definitely. I was able to re-add the camera manually when the stream goes down, but how to detect failure ipcamera streams (to be able to reinitialize it)? There is some plan to support auto reconnection of rtsp streams?

micaelgallego commented 3 years ago

What you mean by "restart the rtsp stream"?

We can explore some kind of "forever automatic retrying" while camera is connected to the session.

Best regards

dottgonzo commented 3 years ago

sorry, i mean to restart the rtsp stream by removing it's connection to openvidu and readd it to the session, but not understand how to know serverside when the stream from rtsp is broken (maybe because the camera restart)

dottgonzo commented 3 years ago

Please, can I have some tip about where to look to be able to investigate ? If I can find a fix, I will be send you a merge request

lionants02 commented 3 weeks ago

4 years ago I tried to fix it by exporting Kurento log to external api and noticed the behavior of log when rtsp error, it will log NOT_FLOWING and in log value connection with session and rtsp link data sent out. What I did next was remove rtsp and reconnect.

The logs that occur when the camera cannot be connected from the beginning and when it is connected but disconnects during use will be different.

The concept I use

flowchart TD
    S("RTSP Reconnect")
    S --> check1{"Camera loses connection"}
    check1 -->|Yes| re[["reconnect"]]

    check1 -->|No| check2{"Camera cannot be connected"}
    check2 -->|Yes| connect[["connect"]]

    check2 -->|No| r("Return")
    re-->r
    connect-->r
  1. Kurento log to external api [link1] I'm not sure if the code still works or maybe it's another file. link2

    • Also export the domainOrPublic variable with the log.
  2. Check Error log, When the camera loses connection after taking a break "MediaFlowInStateChange" "NOT_FLOWING "

    // [Kotlin Programming Language](https://kotlinlang.org/)
    if (flow.endpoint!!.contains("rtsp")
                && flow.mediaType!!.contains("VIDEO")
                && flow.state!!.contains("NOT_FLOWING")
            ){
                 // There should be a delay when disconnecting and reconnecting.
                 reconnect(flow)
            }
  3. When the camera cannot be connected

    if (flow.type!!.contains("INVALID_URI")
                && flow.endpoint!!.contains("rtsp")
            ){
           // There should be a delay.
           connect(flow)
    }

I have a new project coming up that I need to use so I'm back to check it out. And use this board to record my thoughts so I don't forget. Hahaha