Having "setRemoteDescription failed Failed to set remote answer sdp: Called in wrong state: STATE_INPROGRESS" error when attempting multiple calls

896 views
Skip to first unread message

Angel Todorov

unread,
Jul 24, 2015, 11:52:17 AM7/24/15
to EasyRTC
Hi there,
I am developing multi-party video conference.
For specific use-case, the call host can receive multiple call requests (up to 4). When call host accepts all requests, it sends back to each caller peer message indicating that it accepts the request. In its turn, the caller, joins the room and make calls to all room participants. Here is the code, I am using to make this:

// call to all room occupants
var calling;
if (angular.isDefined(calling)) {
    return;
}
var i = 0;
calling = $interval(function () {
    if (i < $scope.callers.length && $scope.callers[i].easyrtcId) {
        if (easyrtc.getConnectStatus($scope.callers[i].easyrtcId) === easyrtc.NOT_CONNECTED) {
            //easyrtc.enableDataChannels($scope.callers[i].easyrtcId);
            easyrtc.call($scope.callers[i].easyrtcId,
                function(easyrtcid) {
                    $log.debug("completed call to " + easyrtcid);
                },
                function(errorCode, errorText) {
                    $log.debug("err:" + errorText);
                    MessageService.error(errorText, locale.getString('room.CALLFAILURE'));
                },
                function(accepted, bywho) {
                    $log.debug((accepted?"accepted":"rejected")+ " by " + bywho);
                }
            );
        }
        ++i;
    } else {
        $interval.cancel(calling);
        calling = undefined;
    }
   
}, 500);

making long story short - I am performing call request to each call participant, holding call request with 500 milliseconds each. However to all call requests succeeded.
The error I received is "setRemoteDescription failed  Failed to set remote answer sdp: Called in wrong state: STATE_INPROGRESS" in easyrtc.js line 4401 in Console.

Any help would be appreciated!

Best Regards,
Angel

Eric Davies

unread,
Jul 24, 2015, 12:03:06 PM7/24/15
to EasyRTC, angel.a...@gmail.com
I think you've probably got a scope problem with your i variable.
Try throwing in a 
   console.log("i=" + i);
just before the easyrtc.call and I suspect you'll see multiple calls being made to the same person.


Angel Todorov

unread,
Jul 26, 2015, 6:43:20 AM7/26/15
to EasyRTC, eric....@priologic.com
Hi Eric,
Once again you are a life savior! I can confirm it was the real problem.
Best Regards,
Angel

Eric Davies

unread,
Jul 26, 2015, 12:53:26 PM7/26/15
to EasyRTC, angel.a...@gmail.com
I've made the same scope error myself more times than I can count. 
Reply all
Reply to author
Forward
0 new messages