Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

"Abandoned" pipelines seemingly not released #613

Open
3 tasks done
neilyoung opened this issue Oct 31, 2021 · 2 comments
Open
3 tasks done

"Abandoned" pipelines seemingly not released #613

neilyoung opened this issue Oct 31, 2021 · 2 comments

Comments

@neilyoung
Copy link

neilyoung commented Oct 31, 2021

Prerequisites

These are MANDATORY, otherwise the issue will be automatically closed.

Issue description

"Abandoned" pipeline is seemingly not released under certain circumstances

Context

Good scenario:

  • Node JS app controls KMS via WS
  • A "sendonly" video session is opened from a browser towards KMS via Node JS app
  • Pipeline handle can be obtained by "kurentoClient.getServerManager().getPipelines()" (pseudo code)
  • If the browser window is closed (w/o doing any pipeline.release()) a couple of seconds later the WebRTCEndpoint as observed by the Node JS app reports a "MediaStateChange" from CONNECTED to DISCONNECTED, the pipeline is released manually and disappears from the report
  • The "getPipelines()" reports an empty array, as expected

Bad scenario (and root of this bug report):

  • Node JS app controls KMS via WS
  • A "sendonly" video session is opened from a browser towards KMS via Node JS app
  • Pipeline handle can be obtained by "kurentoClient.getServerManager().getPipelines()" (pseudo code)
  • The Node JS app is terminated, followed by a termination of the browser. Nobody releases the pipeline manually
  • When the Node JS app returns, it still finds the pipeline as reported above and this pipeline never disappears from the list, even though the garbage collector runs several times on KMS
  • It is still possible to release this pipeline then "manually", but this is not such a good solution, because nothing indicates the stale character of this session

How to reproduce?

On a machine with standard KMS installation:

  • mkdir test && cd test
  • npm init --yes
  • npm i kurento-client
  • nano index.js
  • Copy the test app below into index.js and save
  • node index.js

After 5 seconds and then every 5 seconds you should see a list of pipeline IDs. Close the node app, reopen it. With every new reopen the list of pipeline IDs grows w/o being automatically disposed somewhen.

The test code:

const kurento = require('kurento-client')

const test = async () => {
    try {
        let kurentoClient = await kurento('ws://localhost:8888/kurento', { failAfter: 5 })
        let kurentoServerManager = await kurentoClient.getServerManager()
        setInterval(async () => {
            try {
                let pipelines = await kurentoServerManager.getPipelines()
                console.log(pipelines.map(pipeline => pipeline.id))
            }
            catch (e) {
                console.error(e.message)
            }
        }, 5000)

        let pipeline = await kurentoClient.create('MediaPipeline')
        let webRtcEndpoint = await pipeline.create('WebRtcEndpoint')
        webRtcEndpoint.on('ConnectionStateChanged', (event) => {
            console.log(`ConnectionStateChanged ${JSON.stringify(event)}`)
        })
        webRtcEndpoint.on('MediaStateChanged', (event) => {
            console.log(`MediaStateChanged ${JSON.stringify(event)}`)
        })
        webRtcEndpoint.on('IceComponentStateChange', (event) => {
            console.log(`IceComponentStateChange state ${event.state}, streamId ${event.streamId}, componentId ${event.componentId}`)
        })
        webRtcEndpoint.on('NewCandidatePairSelected', (event) => {
            console.log(`NewCandidatePairSelected, server ${event.candidatePair.localCandidate}`)
            console.log(`NewCandidatePairSelected, client ${event.candidatePair.remoteCandidate}`)
        })
        webRtcEndpoint.on('IceCandidateFound', (event) => {
            console.log(`IceCandidateFound ${event.candidate.candidate}, sdpMid: ${event.candidate.sdpMid}`)
        })
        webRtcEndpoint.on('IceGatheringDone', (event) => {
            console.log(`IceGatheringDone`)
        })

        await webRtcEndpoint.connect(webRtcEndpoint)
        console.log(await webRtcEndpoint.generateOffer())
        await webRtcEndpoint.gatherCandidates()

    }
    catch (e) {
        console.error(e)
    }
}

test()

Expected & current behavior

The pipeline should be released somewhen automatically. There is no RTP stream, which feeds it anymore, shouldn't this pipeline be abandoned automatically somewhen by KMS?

All pipelines are gone (of course) with a restart of KMS

(Optional) Possible solution

Info about your environment

About Kurento Media Server

About your Application Server

  • Programming Language: Node JS
  • Kurento Client version: 6.16.0

About end-user clients

  • Device(s): Mac
  • OS(es): MacOS Big Sur
  • Browser(s): Chrome 95

Run these commands

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"
kurento-media-server --version
Kurento Media Server version: 6.16.1~7.g3f39a10
Found modules:
	'core' version 6.16.1~11.g2007dd8e
	'elements' version 6.16.1~16.g7a1ae52
	'filters' version 6.16.1~2.g1ea55c4
dpkg -l | grep -Pi 'kurento|kms-|gst.*1.5|nice'
no output
gst-inspect-1.5 | grep -E "nice|^kms*"
kmswebrtcendpoint:  webrtcendpoint: WebrtcEndpoint
kmslogooverlay:  logooverlay: logo overlay element
kmsimageoverlay:  imageoverlay: image overlay element
nice:  nicesrc: ICE source
nice:  nicesink: ICE sink
kmselements:  httpendpoint: HttpEndpoint
kmselements:  httppostendpoint: HttpEndpoint
kmselements:  playerendpoint: PlayerEndpoint
kmselements:  dispatcher: Dispatcher
kmselements:  dispatcheronetomany: DispatcherOneToMany
kmselements:  selectablemixer: SelectableMixer
kmselements:  compositemixer: CompositeMixer
kmselements:  alphablending: AlphaBlending
kmsfacedetector:  facedetector: Face Detector element
kmsmovementdetector:  movementdetector: Movement detector element
kmsrecorderendpoint:  recorderendpoint: RecorderEndpoint
kmsrtpendpoint:  rtpendpoint: RtpEndpoint
kmscore:  agnosticbin: Agnostic connector 2nd version
kmscore:  agnosticbin3: Agnostic connector 3rd version
kmscore:  filterelement: FilterElement
kmscore:  hubport: HubPort
kmscore:  kmsaudiomixer: AudioMixer
kmscore:  audiomixerbin: AudioMixerBin
kmscore:  bitratefilter: BitrateFilter
kmscore:  bufferinjector: Buffer injector
kmscore:  passthrough: PassThrough
kmscore:  dummysrc: KmsDummySrc
kmscore:  dummysink: KmsDummySink
kmscore:  dummyduplex: KmsDummyDuplex
kmscore:  dummysdp: KmsDummySdp
kmscore:  dummyrtp: KmsDummyRtp
kmscore:  dummyuri: KmsDummyUri
kmsfaceoverlay:  faceoverlay: Face Overlay element
kmsopencvfilter:  opencvfilter: generic opencv element
@github-actions
Copy link

Hello @neilyoung! 👋 we're sorry you found a bug... so first of all, thank you very much for reporting it.

To know about progress, check in Triage. All issues are considered Backlog Candidates until work priorities align and the issue is selected for development. It will then become part of our official Backlog.

@neilyoung
Copy link
Author

One more observation: If I stay away from KMS for the garbage collection time (don't restart the Node app for 240 s) then the pipelines are removed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant