Home » Android » How to avoid session timeout in Android

How to avoid session timeout in Android

Posted by: admin May 14, 2020 Leave a comment

Questions:

In my Android application am showing live video streaming using LibVLC library. To connect SSH server i have used jsch library.

When i run application, after session connection video runs properly. and when i minimize the app for 3-4 minutes, and resume again still video runs properly. But when i minimize the application for 10 or more minutes and on resume it shows session timeout message.

OnResume() I tried to create session and createPlayer() but still not working .

I have tried by changing session connect time.

Is there is any way to avoid session timeout for long period like 30 minutes.

//** AFTER EDIT**//

I checked after onResume() session is still connected, and error log says Connection reset by peer.

What does that mean? Is ssh tunnel is closed? If yes, how to check ssh tunnel status?

Error log:

08-09 10:52:15.268 6529-21339/com.compdigitec.libvlcandroidsample E/VLC: live555 demux: Failed to connect with rtsp://localhost:8554/video.ts
08-09 10:52:15.268 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core demux: no access_demux modules matched
08-09 10:52:15.268 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core input: creating access ‘rtsp’ location=’localhost:8554/video.ts’, path='(null)’
08-09 10:52:15.268 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core access: looking for access module matching “rtsp”: 15 candidates
08-09 10:52:15.268 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core access: net: connecting to localhost port 8554
08-09 10:52:15.278 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core access: connection succeeded (socket = 36)
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample E/VLC: core access: read error: Connection reset by peer
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: access_realrtsp access: rtsp connected
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample W/VLC: access_realrtsp access: only real/helix rtsp servers supported for now
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample D/VLC: core access: no access modules matched
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample E/VLC: core input: open of rtsp://localhost:8554/video.ts’ failed
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample E/VLC: core input: Your input can’t be opened
08-09 10:52:35.823 6529-21339/com.compdigitec.libvlcandroidsample E/VLC: core input: VLC is unable to open the MRL ‘rtsp://localhost:8554/video.ts’

How to&Answers:

The demux error you are getting is happening at a higher level in the stack. You need to first validate that the underlying SSH connection is still good. To do so, check and if necessary reconnect when your application resumes:

public void onResume() {
    if (!session.isConnected()) {
        reconnect(); // needs to create a new session, open a channel, etc.
    }
}

Once you have validated the SSH connection, you should be able to resume the stream via LibVLC. If however you still see an error at that point, you’ll have to show the code that you use to open / resume the stream.

Answer:

Seems like you are opening a new stream, when you already have an existing stream opened.
Put a check to create a new stream only when the older stream is disconnected.

Following link might add some help:

https://github.com/bastimeyer/livestreamer-twitch-gui/issues/181

Answer:

     public void onResume() {
      if (!session.isConnected()) {
     reconnect(); // needs to create a new session, open a channel, etc.
    }
       }