Track Added and Directly Removed

Hi everyone,

I am using lib-jitsi-meet to create an application with voice chat. Unfortunately, I have encountered a weird issue when two users are in the voice chat. Sometimes, the user that first joined the room ends up not being able to hear the other user. The logs show that a track for the second user was added, but then it got directly removed afterwards. I don’t really understand why. Does anyone have an idea? Here are the debug logs of the client when a user joins:

JITSI - User joined
Logger.js:154 2022-03-10T10:34:29.669Z [modules\xmpp\strophe.jingle.js] <Rr.onJingle>:  Found a JSON-encoded element in session-initiate, translating to standard Jingle.
Logger.js:154 2022-03-10T10:34:29.671Z [modules\xmpp\strophe.jingle.js] <Rr.onJingle>:  (TIME) received session-initiate:	 11085.299999998882
Logger.js:154 2022-03-10T10:34:29.678Z [modules\RTC\TraceablePeerConnection.js] <new ha>:  Using RTCRtpTransceiver#setCodecPreferences for codec selection
index.js:44 SdpSimulcast: using 3 layers
Logger.js:154 2022-03-10T10:34:29.679Z [modules\RTC\TraceablePeerConnection.js] <new ha>:  Create new TPC[id=1,type=JVB]
Logger.js:154 2022-03-10T10:34:29.681Z [JitsiConference.js] <jc._acceptJvbIncomingCall>:  Starting CallStats for JVB connection...
Logger.js:154 2022-03-10T10:34:29.682Z [modules\statistics\RTPStatsCollector.js] <kn.start>:  Using RTCRtpSynchronizationSource for remote audio levels
Logger.js:154 2022-03-10T10:34:29.684Z [modules\RTC\TraceablePeerConnection.js] <ha.addTrack>:  TPC[id=1,type=JVB] adding LocalTrack[1,audio]
index.js:146 Halt: There are no SSRC groups in the remote description.
2Logger.js:154 2022-03-10T10:34:29.717Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] ignored remote 'stream added' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:29.744Z [modules\xmpp\JingleSessionPC.js] <br.sendSessionAccept>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] Sending session-accept
Logger.js:154 2022-03-10T10:34:29.777Z [modules\xmpp\JingleSessionPC.js] <ha.peerconnection.oniceconnectionstatechange>:  (TIME) ICE checking JVB:	 11192.599999999627
Logger.js:154 2022-03-10T10:34:29.822Z [modules\xmpp\JingleSessionPC.js] <ha.peerconnection.oniceconnectionstatechange>:  (TIME) ICE connected JVB:	 11237.900000000373
Logger.js:154 2022-03-10T10:34:29.827Z [modules\xmpp\JingleSessionPC.js] <br.sendIceCandidate>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] sendIceCandidate: last candidate
Logger.js:154 2022-03-10T10:34:29.913Z [modules\xmpp\JingleSessionPC.js] <br.sendIceCandidates>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] sendIceCandidates [{"candidate":"candidate:1243430520 1 udp 2122257663 2002:aaf8:e3e1:1018:5c32:d59:842b:6ef9 56749 typ host generation 0 ufrag yzmG network-id 1 network-cost 50","sdpMid":"0","sdpMLineIndex":0},{"candidate":"candidate:1196289239 1 udp 2122192127 2002:aaf8:e3e1:1018:f9ba:3c31:b20c:7a12 56750 typ host generation 0 ufrag yzmG network-id 2 network-cost 50","sdpMid":"0","sdpMLineIndex":0},{"candidate":"candidate:812732007 1 udp 2122131711 2003:e2:710:ff00:45f4:b488:b58:26cd 56751 typ host generation 0 ufrag yzmG network-id 4 network-cost 10","sdpMid":"0","sdpMLineIndex":0},{"candidate":"candidate:420633993 1 udp 2122066175 2003:e2:710:ff00:d145:56e0:9590:9f41 56752 typ host generation 0 ufrag yzmG network-id 5 network-cost 10","sdpMid":"0","sdpMLineIndex":0},{"candidate":"candidate:1833114227 1 udp 2121998079 192.168.178.37 56753 typ host generation 0 ufrag yzmG network-id 3 network-cost 10","sdpMid":"0","sdpMLineIndex":0}]
Logger.js:154 2022-03-10T10:34:29.946Z [modules\xmpp\strophe.jingle.js] <Rr.onJingle>:  (TIME) received session-initiate:	 11361.900000000373
Logger.js:154 2022-03-10T10:34:29.949Z [modules\RTC\TraceablePeerConnection.js] <new ha>:  Using RTCRtpTransceiver#setCodecPreferences for codec selection
index.js:44 SdpSimulcast: using 3 layers
Logger.js:154 2022-03-10T10:34:29.950Z [modules\RTC\TraceablePeerConnection.js] <new ha>:  Create new TPC[id=2,type=P2P]
Logger.js:154 2022-03-10T10:34:29.950Z [JitsiConference.js] <jc._acceptP2PIncomingCall>:  Starting CallStats for P2P connection...
Logger.js:154 2022-03-10T10:34:29.952Z [modules\RTC\TraceablePeerConnection.js] <ha.addTrack>:  TPC[id=2,type=P2P] adding LocalTrack[1,audio]
Logger.js:154 2022-03-10T10:34:29.988Z [modules\xmpp\JingleSessionPC.js] <br.sendSessionAccept>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] Sending session-accept
Logger.js:154 2022-03-10T10:34:30.067Z [modules\RTC\BridgeChannel.js] <RTCDataChannel.e.onopen>:  datachannel channel opened
Logger.js:154 2022-03-10T10:34:30.067Z [JitsiConferenceEventManager.js] <r.<anonymous>>:  (TIME) data.channel.opened:	 11483.099999999627
Logger.js:154 2022-03-10T10:34:30.144Z [modules\xmpp\JingleSessionPC.js] <br.sendIceCandidates>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] sendIceCandidates [omitted for security]
Logger.js:154 2022-03-10T10:34:30.173Z [modules\RTC\BridgeChannel.js] <Kr.sendNewReceiverVideoConstraintsMessage>:  Sending ReceiverVideoConstraints with {"constraints":{},"lastN":-1,"onStageEndpoints":[],"selectedEndpoints":[]}
Logger.js:154 2022-03-10T10:34:30.173Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.174Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.177Z [JitsiConference.js] <jc.onTransportInfo>:  P2P addIceCandidates
Logger.js:154 2022-03-10T10:34:30.178Z [modules\xmpp\strophe.jingle.js] <Rr.onJingle>:  Found a JSON-encoded element in source-add, translating to standard Jingle.
Logger.js:154 2022-03-10T10:34:30.205Z [modules\xmpp\JingleSessionPC.js] JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] Processing addRemoteStream
index.js:146 Halt: There are no SSRC groups in the remote description.
Logger.js:154 2022-03-10T10:34:30.227Z [modules\xmpp\JingleSessionPC.js] <ha.peerconnection.oniceconnectionstatechange>:  (TIME) ICE checking P2P:	 11643
Logger.js:154 2022-03-10T10:34:30.241Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] adding remote track for stream[id=336fbf24-audio-2,type=audio]
Logger.js:154 2022-03-10T10:34:30.242Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] creating remote track[endpoint=336fbf24,ssrc=3293829606,type=audio,sourceName=undefined]
Conference.js?b70b:94 JITSI - Adding track
Conference.js?b70b:121 JITSI - track ra {_events: {…}, _eventsCount: 2, _maxListeners: undefined, addEventListener: ƒ, off: ƒ, …}
Conference.js?b70b:122 JITSI - track type audio
Logger.js:154 2022-03-10T10:34:30.330Z [modules\xmpp\JingleSessionPC.js] <ha.peerconnection.oniceconnectionstatechange>:  (TIME) ICE connected P2P:	 11746.5
Logger.js:154 2022-03-10T10:34:30.331Z [JitsiConference.js] <jc._setP2PStatus>:  Peer to peer connection established!
Logger.js:154 2022-03-10T10:34:30.331Z [modules\xmpp\JingleSessionPC.js] <br.setMediaTransferActive>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] Queued make video active, audio active task
Logger.js:154 2022-03-10T10:34:30.333Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.333Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.334Z [JitsiConference.js] <jc._removeRemoteTracks>:  Removing remote JVB track: RemoteTrack[userID: 336fbf24, type: audio, ssrc: 3293829606, p2p: false, sourceName: undefined, status: readyState: live, muted: false, enabled: true]
Conference.js?b70b:63 JITSI - Removing track
Conference.js?b70b:82 JITSI - Removing track with id  #336fbf24audio
Logger.js:154 2022-03-10T10:34:30.337Z [JitsiConference.js] <jc._suspendMediaTransferForJvbConnection>:  Suspending media transfer over the JVB connection...
Logger.js:154 2022-03-10T10:34:30.338Z [modules\xmpp\JingleSessionPC.js] <br.setMediaTransferActive>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] Queued make video inactive, audio inactive task
Logger.js:154 2022-03-10T10:34:30.338Z [JitsiConference.js] <jc._onIceConnectionEstablished>:  Starting remote stats with p2p connection
Logger.js:154 2022-03-10T10:34:30.339Z [modules\statistics\RTPStatsCollector.js] <kn.start>:  Using RTCRtpSynchronizationSource for remote audio levels
Logger.js:154 2022-03-10T10:34:30.339Z [modules\statistics\statistics.js] <Function.jn.sendAnalyticsAndLog>:  {"type":"operational","action":"established","source":"p2p","attributes":{"initiator":false}}
Logger.js:154 2022-03-10T10:34:30.361Z [modules\xmpp\JingleSessionPC.js] JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] addRemoteStream - OK
Logger.js:154 2022-03-10T10:34:30.363Z [modules\RTC\TPCUtils.js] <da.setMediaTransferActive>:  TPC[id=1,type=JVB] Suspending audio media transfer.
Logger.js:154 2022-03-10T10:34:30.364Z [modules\RTC\TPCUtils.js] <da.setMediaTransferActive>:  TPC[id=1,type=JVB] Suspending video media transfer.
Logger.js:154 2022-03-10T10:34:30.365Z [JitsiConference.js] Suspended media transfer over the JVB connection !
Logger.js:154 2022-03-10T10:34:30.369Z [modules\RTC\TPCUtils.js] <da.setMediaTransferActive>:  TPC[id=2,type=P2P] Enabling audio media transfer.
Logger.js:154 2022-03-10T10:34:30.369Z [modules\RTC\TPCUtils.js] <da.setMediaTransferActive>:  TPC[id=2,type=P2P] Enabling video media transfer.
Logger.js:154 2022-03-10T10:34:30.371Z [modules\xmpp\JingleSessionPC.js] <br.sendIceCandidate>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] sendIceCandidate: last candidate
Logger.js:154 2022-03-10T10:34:30.374Z [modules\xmpp\JingleSessionPC.js] <ha.peerconnection.onnegotiationneeded>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] onnegotiationneeded fired on TPC[id=1,type=JVB]
index.js:146 Halt: There are no SSRC groups in the remote description.
4Logger.js:154 2022-03-10T10:34:30.400Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] ignored remote 'stream removed' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:30.401Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] remote track removed stream[id=336fbf24-audio-2,trackId=e1c22203-cebb-4967-8b68-9ecc95c90038-2]
2Logger.js:154 2022-03-10T10:34:30.401Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] ignored remote 'stream added' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:30.401Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] adding remote track for stream[id=336fbf24-audio-2,type=audio]
Logger.js:154 2022-03-10T10:34:30.402Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] creating remote track[endpoint=336fbf24,ssrc=3293829606,type=audio,sourceName=undefined]
Logger.js:154 2022-03-10T10:34:30.402Z [JitsiConference.js] <jc.onRemoteTrackAdded>:  Trying to add remote JVB track, when in P2P - IGNORED
2Logger.js:154 2022-03-10T10:34:30.423Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] ignored remote 'stream removed' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:30.424Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] remote track removed stream[id=336fbf24-audio-2,trackId=e1c22203-cebb-4967-8b68-9ecc95c90038-2]
Logger.js:154 2022-03-10T10:34:30.428Z [modules\xmpp\JingleSessionPC.js] <br.notifyMySSRCUpdate>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] Sending source-remove for audio ssrcs=1944473540
Logger.js:154 2022-03-10T10:34:30.647Z [modules\xmpp\JingleSessionPC.js] <br.setReceiverVideoConstraint>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] setReceiverVideoConstraint - max frame height: 720
Logger.js:154 2022-03-10T10:34:30.648Z [modules\xmpp\JingleSessionPC.js] <br.sendContentModify>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] sending content-modify, video senders: both, max frame height: 720
Logger.js:154 2022-03-10T10:34:30.649Z [modules\xmpp\JingleSessionPC.js] <br.modifyContents>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] received remote max frame height: 720
Logger.js:154 2022-03-10T10:34:30.650Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.650Z [modules\xmpp\JingleSessionPC.js] <br.setSenderVideoConstraint>:  JingleSessionPC[session=P2P,initiator=false,sid=5d8d68153859] setSenderVideoConstraint: 720
Logger.js:154 2022-03-10T10:34:30.682Z [modules\RTC\TPCUtils.js] <da.setMediaTransferActive>:  TPC[id=2,type=P2P] Enabling video media transfer.
Logger.js:154 2022-03-10T10:34:30.865Z [modules\xmpp\strophe.jingle.js] <Rr.onJingle>:  Found a JSON-encoded element in source-remove, translating to standard Jingle.
Logger.js:154 2022-03-10T10:34:30.876Z [modules\xmpp\JingleSessionPC.js] JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] Processing removeRemoteStream
interop.js:360 The description does not look like plan-b
toUnifiedPlan @ interop.js:360
ha.setRemoteDescription @ TraceablePeerConnection.js:2382
_responderRenegotiate @ JingleSessionPC.js:1998
_renegotiate @ JingleSessionPC.js:1986
(anonymous) @ JingleSessionPC.js:1813
_processQueueTasks @ AsyncQueue.js:30
process @ async.js:809
setTimeout (async)
process.nextTick.r.nextTick @ async.js:100
(anonymous) @ async.js:768
d @ async.js:46
n @ async.js:753
push @ async.js:782
push @ AsyncQueue.js:60
_addOrRemoveRemoteStream @ JingleSessionPC.js:1830
removeRemoteStream @ JingleSessionPC.js:1719
onJingle @ strophe.jingle.js:303
run @ strophe.umd.js:1875
(anonymous) @ strophe.umd.js:3157
forEachChild @ strophe.umd.js:830
_dataRecv @ strophe.umd.js:3146
_onRequestStateChange @ strophe.umd.js:5012
XMLHttpRequest.send (async)
d @ strophe.umd.js:5123
_processRequest @ strophe.umd.js:5137
_throttledRequestHandler @ strophe.umd.js:5290
_onIdle @ strophe.umd.js:4901
_onIdle @ strophe.umd.js:3881
(anonymous) @ strophe.umd.js:5257
setTimeout (async)
_send @ strophe.umd.js:5256
send @ strophe.umd.js:2583
send @ XmppConnection.js:491
onJingle @ strophe.jingle.js:314
run @ strophe.umd.js:1875
(anonymous) @ strophe.umd.js:3157
forEachChild @ strophe.umd.js:830
_dataRecv @ strophe.umd.js:3146
_onRequestStateChange @ strophe.umd.js:5012
XMLHttpRequest.send (async)
d @ strophe.umd.js:5123
_processRequest @ strophe.umd.js:5137
_throttledRequestHandler @ strophe.umd.js:5290
_onIdle @ strophe.umd.js:4901
_onIdle @ strophe.umd.js:3881
(anonymous) @ strophe.umd.js:5257
setTimeout (async)
_send @ strophe.umd.js:5256
send @ strophe.umd.js:2583
sendIQ @ strophe.umd.js:2740
sendIQ @ XmppConnection.js:511
notifyMySSRCUpdate @ JingleSessionPC.js:2572
(anonymous) @ JingleSessionPC.js:611
Promise.then (async)
e @ JingleSessionPC.js:608
_processQueueTasks @ AsyncQueue.js:30
process @ async.js:809
setTimeout (async)
process.nextTick.r.nextTick @ async.js:100
(anonymous) @ async.js:768
d @ async.js:46
n @ async.js:753
push @ async.js:782
push @ AsyncQueue.js:60
peerconnection.onnegotiationneeded @ JingleSessionPC.js:616
peerconnection.onnegotiationneeded @ TraceablePeerConnection.js:342
r @ utils.js:46
index.js:146 Halt: There are no SSRC groups in the remote description.
2Logger.js:154 2022-03-10T10:34:30.902Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] ignored remote 'stream added' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:30.902Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackAdded>:  TPC[id=1,type=JVB] adding remote track for stream[id=336fbf24-audio-2,type=audio]
Logger.js:154 2022-03-10T10:34:30.911Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] remote track removed stream[id=336fbf24-audio-2,trackId=e1c22203-cebb-4967-8b68-9ecc95c90038-2]
Logger.js:154 2022-03-10T10:34:30.912Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] Removed track not found for stream[id=336fbf24-audio-2,trackId=e1c22203-cebb-4967-8b68-9ecc95c90038-2]
r @ Logger.js:154
ha._remoteTrackRemoved @ TraceablePeerConnection.js:1080
(anonymous) @ TraceablePeerConnection.js:316
2Logger.js:154 2022-03-10T10:34:30.912Z [modules\RTC\TraceablePeerConnection.js] <ha._remoteTrackRemoved>:  TPC[id=1,type=JVB] ignored remote 'stream removed' event for non-user stream[id=mixedmslabel]
Logger.js:154 2022-03-10T10:34:30.918Z [modules\xmpp\JingleSessionPC.js] JingleSessionPC[session=JVB,initiator=false,sid=2qvejvfmntjof] removeRemoteStream - OK

Any help would be appreciated. Kind regards.

Was the audio-track added to the meeting from the start?

We only add tracks when we receive a TRACK_ADDED event, so: conference.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrackAdded); When the event is triggered, we log “JITSI - Adding track”.

So therefore, we do not add remote audio tracks from the start and rather once the listener is triggered.
However, the local audio track is created right after we connect to the connection, so:

connection.connect();
createLocalTrack();

Yes, I meant the local tracks. How and when exactly are you adding them to the conference?

There are two places where we potentially add local tracks to the connection.
The first one is in the callback after creating local tracks which is done directly after calling connection.connect() as seen above. Then, the following code is executed

JitsiMeetJS.createLocalTracks(...).then(
    (tracks) => {
        this.localTracks.push(tracks[0]);
        ...
        // If the new track is created after joining the connection,
        // add the track to the room
        if (this.isJoined) {
            conference.addTrack(tracks[0]);
        }
        ...
    });

The other place is when we join a Conference, so on the callback for CONFERENCE_JOINED:

let onConferenceJoined = function () {
    this.isJoined = true;
    // Add all local tracks to the room
    for (let i = 0; i < this.localTracks.length; i++) {
        conference.addTrack(this.localTracks[i]);
        // Set muted state
        ...
    }
}.bind(this);

I’d suggest you try this: create the tracks and add them to the conference, and after that, do conference.join().

Great suggestion because it seems to have done the trick :smiley:
I will test it some more to absolutely make sure that we no longer have this problem and then probably resolve this issue. Thank you very much for your great and quick help, saghul!

1 Like

i do this but the problem is still same track is added and then its removed

as you can see there

its resolved