node.jssocket.iowebrtcrtcmulticonnection

RTCMulticonnection room join keeps throwing error : Session-Descriptions not found. Rechecking


I'm using RTCMulticonnection MultiRTC script to capture and stream multiple user cameras.

I guess, If any user refresh page then session keeps alive in background even I've added page unload event

window.onbeforeunload = function() {
    rtcMultiConnection.close();
};

my problem is that joining a room after refresh keeps throwing error/warning message Session-Descriptions not found. Rechecking...

Why session description not found? I've checked RTCMulticonnection js and this error is throwing from below function.

function joinSession(session, joinAs) {
        if (isString(session)) {
            connection.skipOnNewSession = true;
        }
        console.log(session);
        console.log(joinAs);
        if (!rtcMultiSession) {
            log('Signaling channel is not ready. Connecting...');
            // connect with signaling channel
            initRTCMultiSession(function() {
                log('Signaling channel is connected. Joining the session again...');
                setTimeout(function() {
                    joinSession(session, joinAs);
                }, 1000);
            });
            return;
        }

        // connection.join('sessionid');
        if (isString(session)) {
            if (connection.sessionDescriptions[session]) {
                session = connection.sessionDescriptions[session];
            } else
                return setTimeout(function() {
                    log('Session-Descriptions not found. Rechecking..');
                    joinSession(session, joinAs);
                }, 1000);
        }

        // connection.join('sessionid', { audio: true });
        if (joinAs) {
            return captureUserMedia(function() {
                session.oneway = true;
                joinSession(session);
            }, joinAs);
        }

        if (!session || !session.userid || !session.sessionid) {
            error('missing arguments', arguments);

            var error = 'Invalid data passed over "connection.join" method.';
            connection.onstatechange({
                userid: 'browser',
                extra: {},
                name: 'Unexpected data detected.',
                reason: error
            });

            throw error;
        }

        if (!connection.dontOverrideSession) {
            connection.session = session.session;
        }

        var extra = connection.extra || session.extra || {};

        // todo: need to verify that if-block statement works as expected.
        // expectations: if it is oneway streaming; or if it is data-only connection
        // then, it shouldn't capture user-media on participant's side.
        if (session.oneway || isData(session)) {
            rtcMultiSession.joinSession(session, extra);
        } else {
            captureUserMedia(function() {
                rtcMultiSession.joinSession(session, extra);
            });
        }
    }

Solution

  • Upgraded my application with RTCMulticonnection version v3, also used socket.io instead of WebSocket, earlier I was using WebSocket.