PSA: PeerConnection.createAnswer will now check signaling state

753 views
Skip to first unread message

steve...@webrtc.org

unread,
Feb 5, 2018, 2:04:27 AM2/5/18
to discuss-webrtc
Hi,

PeerConnection.createAnswer will now fail if the signaling state is not 'have-remote-offer' or 'have-local-pranswer', in accordance with the WebRTC specification. This will affect the PeerConnection API on all platforms (C++, Javascript, Java, Objective C). Currently it looks like it will reach Chrome in M66.

Most uses of PeerConnection should not be affected since createAnswer is only called once in the normal signaling flow.

An affected case: Some applications use a second call to createAnswer after ICE gathering has completed to get an answer with all the local ICE candidates. This will no longer work since createAnswer cannot be called after setLocalDescription with an answer (the signaling state will be 'stable'). The fix is to look at the answerer's localDescription which is identical to the created answer and will have been updated with all the gathered ICE candidates.

Best,
Steve

harshendra singh

unread,
Feb 19, 2018, 2:17:58 AM2/19/18
to discuss-webrtc
I am still getting the error can you please help me on this

harshendra singh

unread,
Feb 19, 2018, 3:15:49 AM2/19/18
to discuss-webrtc
please help me on this  below is my code.
signallingServer.onGuestJoined = function() {
//onGuestJoined  is workin properly
        trace('guest joined!')
//called when partner joind the call
        // set local description and send to remote
        localPeerConnection.createOffer(function(sessionDescription) {
            trace('set local session desc with offer');

            localPeerConnection.setLocalDescription(sessionDescription);
           //
            //localPeerConnection.setRemoteDescription(sessionDescription);
            // send local sdp to remote
            signallingServer.sendSDP(sessionDescription);
        });
    }

    // got sdp from remote
    signallingServer.onReceiveSdp = function(sdp) {
        // get stream again
debugger;
        localPeerConnection.addStream(localStream);
        trace(localStream)

        // if local was the caller, set remote desc
        if (localIsCaller) {
            trace('is caller');
            trace('set remote session desc with answer');
            localPeerConnection.setRemoteDescription(new RTCSessionDescription(
                sdp));
        }
        // if local is joining a call, set remote sdp and create answer
        else {
            trace('set remote session desc with offer');
          
            localPeerConnection.setRemoteDescription(new RTCSessionDescription(
                sdp), function() {
                    trace('make answer')
                   // console.log(sdp);
                localPeerConnection.createAnswer(function(sessionDescription) {
//call is not getting inside error DOMException: CreateAnswer called with invalid media streams
                    // set local description
                    trace('set local session desc with answer');
                    localPeerConnection.setLocalDescription(
                        sessionDescription);
                    // send local sdp to remote too
                    signallingServer.sendSDP(sessionDescription);
                }, function (e) {
                    console.log("Could not set remote description. Reason: " + e);
                });
                });
Reply all
Reply to author
Forward
0 new messages