Skip to content

Axis camera stream ended after hitting session timeout

Hi!

I posted this above on libVLC discord (#libvlcsharp channel)

Hi, I have been using the libvlcsharp package for a couple of days to display a stream in a winforms application. The problem I have is that the stream is ending after 60s which I have concluded is a session timeout. From what I have understood is that I need to send "keep alive" messages to keep the stream going and ppl have said they have used the GET_PARAMETER as a way to fix this. I have tried different media options values but to no avail. What am I missing? Thanks!

OUTPUT VS Studio (verbose=2)

...
Opening connection to 10.x.x.x, port 554...
...remote connection opened
Sending request: OPTIONS rtsp://10.x.x.x:554/axis-media/media.amp RTSP/1.0

CSeq: 2
User-Agent: LibVLC/3.0.12 (LIVE555 Streaming Media v2016.11.28)
Received 201 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK

CSeq: 2
Public: OPTIONS, DESCRIBE, ANNOUNCE, GET_PARAMETER, PAUSE, PLAY, RECORD, SETUP, SET_PARAMETER, TEARDOWN
Server: GStreamer RTSP server
Date: Tue, 20 Apr 2021 10:23:02 GMT
...

I received an answer from a user

Does it happen in VLC too ? I have a bug opened for that, let me check oh, I think I never properly reported that one and only asked VideoLAN directly :/ I have such timeouts with Axis cameras and RTSP. We have tracked the issue down to a mutex that is held for too long and weren't able to find out why. In the meantime, I just applied a patch and rebuilt my own libvlc version to increase the rate at which libvlc sends keepalives Here's the patch I applied

...
Date: Mon, 22 Jul 2019 13:21:57 +0200
Subject: [PATCH] Increase RTSP timeout margin to 10 seconds

---
 modules/access/live555.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 26db2d6f24..57104e2cd1 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -1273,11 +1273,11 @@ static int Play( demux_t *p_demux )
 
         /* Retrieve the timeout value and set up a timeout prevention thread */
         int timeout = p_sys->rtsp->sessionTimeoutParameter();
-        if( timeout <= 2 )
+        if( timeout <= 10 )
             timeout = 60; /* default value from RFC2326 */
         msg_Dbg( p_demux, "We have a timeout of %d seconds", timeout );
 
-        mtime_t interval = (timeout - 2) * CLOCK_FREQ;
+        mtime_t interval = (timeout - 10) * CLOCK_FREQ;
         vlc_timer_schedule( p_sys->timer, false, interval, interval);
     }
     p_sys->i_pcr = VLC_TS_INVALID;
-- 
2.22.0.windows.1

For now as a workaorund, I have to play the media again every time the session has a timeout. Don't know if this is a bug or not, or if I am doing something wrong.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information