Home > Forum > reconnect to rtsp stream

reconnect to rtsp stream

Sep 22, 2021
Jonathan Spiegelglas wrote
I'm using the IP capture example to preview and record an RTSP stream from a security camera.
I would like to make the software more robust and initiate a reconnect if the connection was not successful.
the main use case is to be able to start the software and only then connecting the camera. The software should connect whenever the camera becomes online.

What should be the best way to achieve that? I'm already listening to OnError and would like to initiate a reconnect on specific errors.

Thanks
Reply
4 Answers
Sep 22, 2021
Roman Miniailov agent wrote
Hi

You can use OnNetworkSourceDisconnect event to catch camera disconnect and start reconnecting in your code.

OnError event can be used to catch camera connection issues.
Sep 22, 2021
Jonathan Spiegelglas wrote
videoCapture.Start() does the connecting, so I should call Start() on each disconnect event? I don't see any reconnect option.
Sep 22, 2021
Jonathan Spiegelglas wrote
If no connection was established I will never get a disconnect event, but I will get an error event with "source - unable to connect"
I think I must react to this error if I wish to be able to connect to an IP cam that becomes online after my app is running.

Is there another option to obtain that?
Sep 22, 2021
Roman Miniailov agent wrote
Yes, you should call Stop() and Start() on the disconnect event.

You can use the IP_Camera_CheckAvailable method as an alternative to a real connection.