0

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);
            });
        }
    }
Bhaumik Pandhi
  • 2,655
  • 2
  • 21
  • 38
  • Are you using [socketio-over-nodejs](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) or Firebase? – Muaz Khan Aug 03 '17 at 14:18
  • @MuazKhan, I'm using websocket, neither socketio nor Firebase – Bhaumik Pandhi Aug 03 '17 at 14:20
  • Sorry need to confirm again, [websockets over nodejs](https://github.com/muaz-khan/WebRTC-Experimeent/tree/master/websocket-over-nodejs) or your own custom websockts implementation? – Muaz Khan Aug 03 '17 at 14:31
  • still not sure what are you talking about, please have a look over this [node file](https://kopy.io/3Fjh2), I guess its normal websocket – Bhaumik Pandhi Aug 03 '17 at 14:40
  • You are using [WebSocekts-over-Nodejs](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/websocket-over-nodejs/signaler.js) Here is a reliable socket.io alternative: [rtcmulticonnection-client](https://github.com/muaz-khan/Reliable-Signaler/tree/master/rtcmulticonnection-client) – Muaz Khan Aug 03 '17 at 14:53
  • BTW, it seems that "onclose" event isn't firing on server-side: [signaler.js#L45](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/websocket-over-nodejs/signaler.js#L45) This event makes sure to remove old channels. – Muaz Khan Aug 03 '17 at 14:54
  • You should manually remove channels if someone leaves. (i.e. via "onmessage" event on server-side). You should check presence of the channel before joining it....if channel is present on server, then send channel_initiator a "PING" message. If channel_initiator doesn't replies for 3-seoncds then consider channel_is_closed. Now try to remove channelf or server or override it or set new initiator. – Muaz Khan Aug 03 '17 at 14:56
  • I'll give you updated `signaler.js` a few hours later. – Muaz Khan Aug 03 '17 at 14:57
  • It will have integration of [rtcmulticonnection-client](https://github.com/muaz-khan/Reliable-Signaler/tree/master/rtcmulticonnection-client) ? – Bhaumik Pandhi Aug 03 '17 at 14:59
  • Yep, you can use rtcmulticonnection-client. Otherwise you can use any WebSockets/Socket.io server (i.e. external servers or codes): [Signaling.md](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Signaling.md) i.e. you can write your own websocekts server. It will give you full control over how to handle and store channels on server-side. – Muaz Khan Aug 03 '17 at 15:02
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/150976/discussion-between-pandhi-bhaumik-and-muaz-khan). – Bhaumik Pandhi Aug 03 '17 at 15:05

1 Answers1

1

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

Bhaumik Pandhi
  • 2,655
  • 2
  • 21
  • 38