Search code examples
node.jswebrtckurento

Answer SDP Error Kurento NodeJS server with vanilla webRTC client


I've been developing an application to record a session from the browser using the Kurento Media Server. I've set up the backend using the kurento-client library and used the vanilla WebRTC API on the front end.

The offer is generated at the client side and the answer is returned back from the server.

The issue arises during the setRemoteDescription method at the client side.

I'm getting the error as shown below

Uncaught (in promise) TypeError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': The provided value is not of type 'RTCSessionDescriptionInit'.

console logging the received SDP yields me the following value.

v=0
o=- 3858259838 3858259838 IN IP4 0.0.0.0
s=Kurento Media Server
c=IN IP4 0.0.0.0
t=0 0
a=extmap-allow-mixed:
a=msid-semantic: WMS EkyCjRfgsyNQMlKh9vmRFVBIlCgbgNt51tst
a=group:BUNDLE 0 1
m=audio 1 UDP/TLS/RTP/SAVPF 111 0
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=mid:0
a=rtcp:9 IN IP4 0.0.0.0
a=rtpmap:111 opus/48000/2
a=rtpmap:0 PCMU/8000
a=setup:active
a=rtcp-mux
a=fmtp:111 minptime=10;useinbandfec=1
a=ssrc:2441312662 cname:user4258135824@host-a3760c98
a=ice-ufrag:u7MJ
a=ice-pwd:uAgK+b4b5eK2333Z+qQZnP
a=fingerprint:sha-256 BD:6C:C8:40:7C:30:60:30:76:63:CC:28:20:D3:81:5F:EE:5A:6D:B0:C4:AA:09:37:70:8E:13:55:51:81:4B:37
m=video 1 UDP/TLS/RTP/SAVPF 96 127 125 108 124 123 35
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=mid:1
a=rtcp:9 IN IP4 0.0.0.0
a=rtpmap:96 VP8/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000
a=rtpmap:124 H264/90000
a=rtpmap:123 H264/90000
a=rtpmap:35 H264/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 ccm fir
a=rtcp-fb:35 nack
a=rtcp-fb:35 nack pli
a=setup:active
a=rtcp-mux
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=fmtp:35 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f
a=ssrc:3201711112 cname:user4258135824@host-a3760c98
a=ice-ufrag:u7MJ
a=ice-pwd:uAgK+b4b5eK2333Z+qQZnP
a=fingerprint:sha-256 BD:6C:C8:40:7C:30:60:30:76:63:CC:28:20:D3:81:5F:EE:5A:6D:B0:C4:AA:09:37:70:8E:13:55:51:81:4B:37

I've provided the code segment below which throws the error.

socket.on("credentials", async({ sdp, ice} ) => {
    try {
        if(sdp) {
            console.log(sdp)
            await pc.setRemoteDescription(sdp)
            console.log('set')
        }
        else if(ice) {
            await pc.addIceCandidate(ice)
            console.log('ice set')
        }
    }
    catch(error) {
        console.log(error)
    }
})

Is this not the correct format for the answer SDP? Some help to solve this issue is much appreciated.


Solution

  • You have a problem with your terminology. The SDP itself is the string starting with v=.... However, the setRemoteDescription call expects a RTCSessionDescriptionInit argument, i.e. an object with {type, sdp}.

    That type (offer or answer typically) should also come from your signaling.