JonasVautherin
JonasVautherin

Reputation: 8033

WebRTC not adding datachannel in SDP answer

I can successfully create a datachannel by calling peerConnection.createDataChannel("some/label") and then peerConnection.createOffer(), in which case the datachannel appears in the SDP offer (i.e. there is an m=application there).

But now I want the other peer to create the datachannel, and therefore have it appear in the SDP answer. Same thing: I call createDataChannel before peerConnection.createAnswer(). Except that this time, I don't see an m=application in the SDP answer.

Shouldn't it be possible to create a datachannel from the second peer, and shouldn't it appear in the SDP answer?

My code looks like this:

if (type === 'offer') {
    peerConnection.createDataChannel("some/channel");
    peerConnection.createAnswer().then(createdDescription).catch(errorHandler);
}

I tried with both Firefox and Google Chrome, and I have the same issue, i.e. I don't see an m=application in the SDP answer.

Upvotes: 0

Views: 483

Answers (1)

Philipp Hancke
Philipp Hancke

Reputation: 17305

SDP follows an "offer-answer model" described in RFC 3264. If the offer did not negotiate datachannel, the answer can not contain an additional m-line negotiating it. The answerer will, after sending their answer, have to send an additional offer with a datachannel m-line. The negotiationneeded event may fire to indicate this is required.

Upvotes: 3

Related Questions