Skip to main content

Are timing requirements in webRtc between calling setRemoteDescription and addIceCandidate?

I have implemented webrtc in 2 browsers that physically work on one local machine (one browser I will call as "local", another - "remote"). The browser - Firefox 112.0.1, TURN, STUN servers are not used.

All strings (offer, answer, ice candidates) are transferred from one to another browser manually (slow transfer - via copy and paste). "Remote" gets an offer from the "local" and processes it by rtc2_RegisterRemoteOffer (see code below). This function creates answer of the "remote". Then: (1) the negotiationneeded event fired on the "remote", (2) because of (1) "remote" creates offer and generates it's own ice candidates (up to here neither "local" nor "remote" ice candidates I didn't transfer to each other). (3) Then after few seconds on the "remote" iceconnectionstate fired with the status failed.

The questions are:

  1. What may be a reason of iceconnectionstate gets failed - see (3) ?
  2. Could this happen because I didn't have enough time to send any ice candidate from the "local" to the "remote" after sending offer ?
  3. Is the case (2) - is correct behavior ? Should the "remote" create your own answer when it processes the answer of the "local" ?
  4. If it shouldn't (question 3), then how the "remote" should correctly process it's own negotiationneeded event ?

The code of the "rtc2_RegisterRemoteOffer"

   function rtc2_RegisterRemoteOffer(remoteOfferText) {
        // Register an offer of a remote machine..
        // Input:
        //      - remoteOfferText - string - offer text.

        let stateStr = webRtc.peerConnection.signalingState;

        let logMsg = "rtc2_RegisterRemoteOffer is called. State = " + stateStr;
        DisplayLogMessage(logMsg);
        console.log(logMsg);

        console.log("==remoteOfferText==" + remoteOfferText);
        console.log(remoteOfferText);
        remoteOfferObj = {type: "offer", sdp: remoteOfferText};
        let remoteDescr = null;
        try {
            remoteDescr = new RTCSessionDescription(remoteOfferObj);
        }
        catch (e) {
            remoteDescr = null;
            DisplayErrMessage("Can't create SDP. Errmsg = " + e.message);
        }

        if (remoteDescr === null) {
            // error - do nothing
            DisplayErrMessage("remoteDescr === null !!!");
        }
        else {
            // set remote description
            let remotedescrPromise = webRtc.peerConnection.setRemoteDescription(remoteDescr)
            .then(function Resolve_rdp() {
                let msg = "rtc2_RegisterRemoteOffer.setRemoteDescription -- fulfilled";
                DisplayLogMessage(msg);
                console.log("===> ", msg);
            },

            function Reject_rdp(e) {
                let msg ="rt2c_RegisterRemoteOffer.setRemoteDescription REJECTED. Msg = " + e.message;
                DisplayErrMessage(msg);
                console.log("===> ", msg);

            }
            );  // let remotedescrPromise =

            stateStr = webRtc.peerConnection.signalingState;
            DisplayLogMessage("rtc2_RegisterRemoteOffer - Creating answer for the remote. State = " + stateStr);

            // create an answer to the remote offer

            let answerTextPromise = webRtc.peerConnection.createAnswer().then(
                // resolve
                function resolve_createAnswer(answer) {
                    // answer is generated

                    stateStr = webRtc.peerConnection.signalingState;
                    let msg = "rtc2_RegisterRemoteOffer.createAnswer - resolved. State = " + stateStr;
                    DisplayLogMessage(msg);
                    console.log(msg);
                    // (***) HERE I get:
                    // rtc2_RegisterRemoteOffer.createAnswer - resolved. State = have-remote-offer
                    // set the answer as the local description
                    webRtc.peerConnection.setLocalDescription(answer,

                        function resolve_setLocalDescription_answer() {
                            // resolve -- local description is set
                            console.log("===> ", "rtc2_RegisterRemoteOffer.SetLocalDescription fulfilled.");
                            // ----------------------------------------------------
                            // (***) HERE I get: the message above
                        },
                        function reject_setLocalDescription_answer() {
                            // resolve -- local description is set
                            console.log("ERROR = (setLocalDescription in rtc_RegisterRemoteOffer) is REJECTED");
                        }
                    );
                    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                    // Display local answer for the remote
                    PutLocalAnswerText(answer.sdp);
                    DisplayStatus("Send answer to a remote");

                    // --- try to add local audio/video tracks to the remote ---
                    let tracksAdded = rtc2_addTracks();
                    if (tracksAdded) {
                        // our tracks sent to the remote
                        let msg = "rtc2_RegisterRemoteOffer_Our tracks sent on remote answer.";
                        DisplayLogMessage(msg);
                        console.log(msg);
                    }
                    else {

                        // can't access <mediaDevices>
                        let msg = "ERR1 - rtc_RegisterRemoteOffer_Our tracks WERE NOT sent on remote answer.";
                        DisplayErrMessage(msg);
                        console.log(msg);
                    }

                },
                function reject_createAnswer(e) {
                    let msg = "rt2c_RegisterRemoteOffer.createAnswer - REJECTED. Msg = " + e.message +
                                " State = " + stateStr;
                    DisplayErrMessage(msg);
                    console.log(msg);

                }

            );
        } // if (remoteDescr === null) else

    }   // function rtc2_RegisterRemoteOffer

The offer of the "local"

v=0
o=mozilla...THIS_IS_SDPARTA-99.0 672388715268626096 0 IN IP4 0.0.0.0
s=-
t=0 0
a=sendrecv
a=fingerprint:sha-256 65:F6:31:2A:FF:DD:7C:E1:89:83:C6:F1:8C:61:25:8F:E4:AD:0A:B6:8A:A7:D0:A3:0E:E0:DF:C8:99:5F:85:73
a=group:BUNDLE 0
a=ice-options:trickle
a=msid-semantic:WMS *
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=sendrecv
a=ice-pwd:e0e9063fdcde2bd9f4c3068accca0907
a=ice-ufrag:4386e8e0
a=mid:0
a=setup:actpass
a=sctp-port:5000
a=max-message-size:1073741823
Via Active questions tagged javascript - Stack Overflow https://ift.tt/JdeyXA2

Comments

Popular posts from this blog

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to split a rinex file if I need 24 hours data

Trying to divide rinex file using the command gfzrnx but getting this error. While doing that getting this error msg 'gfzrnx' is not recognized as an internal or external command Trying to split rinex file using the command gfzrnx. also install'gfzrnx'. my doubt is I need to run this program in 'gfzrnx' or in 'cmdprompt'. I am expecting a rinex file with 24 hrs or 1 day data.I Have 48 hrs data in RINEX format. Please help me to solve this issue. source https://stackoverflow.com/questions/75385367/how-to-split-a-rinex-file-if-i-need-24-hours-data