yang Joe
yang Joe

Reputation: 51

WebRTC The ICE candidate could not be added

I am trying to establish a p2p audio/video connection b/w two peers. Following: Getting started with WebRTC.

It works fine at my home in LAN Environment between 2 PCs, but throws an error message when running at my company's LAN Environment, there is part the javascript

function processSignalingMessage(message) {
        var msg = JSON.parse(message);

        if (msg.type === 'offer') {
            // Callee creates PeerConnection
            if (!initiator && !started)
                maybeStart();

            // We only know JSEP version after createPeerConnection().
            if (isRTCPeerConnection)
                pc.setRemoteDescription(new RTCSessionDescription(msg));
            else
                pc.setRemoteDescription(pc.SDP_OFFER,
                        new SessionDescription(msg.sdp));

            doAnswer();
        } else if (msg.type === 'answer' && started) {
            pc.setRemoteDescription(new RTCSessionDescription(msg));
        } else if (msg.type === 'candidate' && started) {
            var candidate = new RTCIceCandidate({
                sdpMLineIndex : msg.label,
                candidate : msg.candidate
            });
            pc.addIceCandidate(candidate);
        } else if (msg.type === 'bye' && started) {
            onRemoteHangup();
        }
    }

when the first user recieved message "type":"candidate",get wrong

and part of the console log:

Upvotes: 5

Views: 18585

Answers (1)

wontonsoup
wontonsoup

Reputation: 142

I think you can create the ICE candidate message by using just the msg.candidate,

var candidate = new RTCIceCandidate(msg.candidate);

And pass that into the addIceCandidate function

Upvotes: 0

Related Questions