Called in wrong state: kStable

279 views
Skip to first unread message

Erik Dvorčák

unread,
Sep 24, 2020, 10:22:25 AM9/24/20
to SIP.js
Hello,

I facing with issue about sessionDescriptionHandler, can you advice me, whats going wrong? Its not every time its more rare like reguraly but it's serious problem. 
I'am using SIP.js 0.15.10 (Web/SessionDescriptionHandler)

Error:

InvalidStateError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable
logger: console
arguments: [{
"message":"Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable",
"name":"InvalidStateError",
"stack":"Error: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable"
}]

SESSION_DESCRIPTION_HANDLER_ERROR: Error with Session Description Handler
logger: console
arguments: [{
"code":8,
"name":"SESSION_DESCRIPTION_HANDLER_ERROR",
"method":"setDescription",
"error":"[object DOMException]",
"message":"Error with Session Description Handler",
"type":27,
"stack":"SESSION_DESCRIPTION_HANDLER_ERROR: Error with Session Description Handler\n at t [as constructor] 
....}]

thanks
Erik

Eric Green

unread,
Sep 28, 2020, 5:35:33 AM9/28/20
to SIP.js
Upgrade to 0.17.X please.

Erik Dvorčák

unread,
Nov 4, 2020, 3:44:21 PM11/4/20
to SIP.js
Hello, I upgraded to last version. 

Error is still there and I found the case when it's happening.
Sorry I cannot have access for copy the trace (I would have to rewrite it manually) .. But I tried describe every step preciously

onProgressFunction (which I use to setup early media) -> https://gist.github.com/7c37c3bdbe03ec12ae0433b85cd81ba5.git

Is it bug? or bad implementation?

Flow: 

// IMPORTANT INFO: ALL steps below was logged in the same time 18:11:11 (I think the problem is in fast (immediately) income of 200 w/SDP after 183 w/SDP)

received 183 (with SDP)
Inviter.onProgress
sdh.hasDescription
sdh.setDescription
sdh.getLocalMediaStream
sdh.applyModifiers
sdh.setRemoteSessionDescription
received 200 (with SDP)
State change to "Accepted" on INVITE client transaction with id z9hG4bK5237512
Inviter.onAccept
sdh.hasDescription
sdh.setDescription
sdh.getLocalMediaStream
sdh.applyModifiers
sdh.setRemoteSessionDescription
sdh.oniceconnectionstatechange checking
sdh.ontrack audio enabled
sdh.setRemoteTrack
sdh.setRemoteTrack - adding remote audio track
sdh.onsignalingstatechange stable
sdh.setDescription failed - InvalidStateError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable
sdh.setAnswer: SDH setDescription rejected...
sip.Inviter | Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable


Erik

Dátum: pondelok 28. septembra 2020, čas: 11:35:33 UTC+2, odosielateľ: Eric Green

Eric Green

unread,
Nov 5, 2020, 5:02:53 AM11/5/20
to SIP.js
The problem is that you are manually setting SDP in your onProgressFunction. So this is what I believe is happening.

-> Invite (SDP)  - getLocalDescription. state hasLocalOffer.
<- 18X Progress (SDP) - setRemoteDescription. state stable.
<- 200 OK (SDP) - setRemoteDescription. error!!

Do not call setDescription in the progress callback. Use SIP.js built in support for early media.

Erik Dvorčák

unread,
Nov 5, 2020, 5:12:22 AM11/5/20
to SIP.js
Thank you!

Dátum: štvrtok 5. novembra 2020, čas: 11:02:53 UTC+1, odosielateľ: Eric Green

Ghanshyam Katriya

unread,
Feb 3, 2021, 6:12:01 AM2/3/21
to SIP.js
Hello Erik,

Can you guide me how did you handled early media with newer version?

Slavik Bialik

unread,
Feb 4, 2021, 1:03:18 PM2/4/21
to SIP.js
Ghanshyam Katriya ,  If you are talking about enabling early media on outbound calls, so just set it like that:
var inviterOptions: InviterOptions = {
earlyMedia: true
}

var inviter = new Inviter(userAgent, target, inviterOptions);
inviter.invite();


Ghanshyam Katriya

unread,
Feb 5, 2021, 5:13:57 AM2/5/21
to SIP.js
I see documentation of onaddtrack in this link https://github.com/onsip/SIP.js/blob/master/docs/session-description-handler.md but SessionDescriptionHandler is available in Established state only. How did you managed addTrack event and capture streams before Established session?
Reply all
Reply to author
Forward
0 new messages