Encountered an error while attempting to establish a PeerConnection: Error occurred while trying to initialize 'RTCSessionDescription': the first parameter ('descriptionInitDict') is not recognized

https://i.sstatic.net/9n1IP.png
Frontend code:-

Frontend code goes here...

Backend Code:

 Backend code goes here...

I encountered an error: Failed to create PeerConnection, exception: Failed to construct 'RTCSessionDescription': parameter 1 ('descriptionInitDict') is not an object.

I also received an error message: Uncaught (in promise) DOMException: Failed to set remote offer sdp: Called in wrong state: kHaveLocalOffer

Answer №1

This code snippet:

pc.createOffer().then(setDescription).catch(errorHandler);

    function setDescription(description) {
        console.log('Received description', description);

        pc.setLocalDescription(description).then(function() {
            console.log("Sending SDP");
            socket.emit('signal', {'sdp': description});
        }).catch(errorHandler);
    }

Next, you need to handle the received SDP:

    function gotMessageFromServer(signal) {
        console.log('Received message from server', signal);

        if(signal.sdp) {
            console.log("Setting remote description: ", signal);
            pc.setRemoteDescription(new RTCSessionDescription(signal.sdp)).then(function() {
                // Only create answers in response to offers
                if(signal.sdp.type === 'offer') {
                    console.log("Sending answer");
                    pc.createAnswer().then(setDescription).catch(errorHandler);
                }
            }).catch(errorHandler);
        } else if(signal.ice) {
            console.log('Received remote ICE candidate: ', signal);
            pc.addIceCandidate(new RTCIceCandidate(signal.ice)).catch(errorHandler);
        }
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Intersection Observer is functioning properly as elements vanish once they finish appearing

New to this forum and looking forward to receiving assistance and making some fantastic connections! Currently working on my personal portfolio with the goal of getting it online for job hunting purposes, but encountering some challenges along the way. T ...

Encountering "Uncaught TypeError: Cannot read properties of undefined" while trying to render data in React, with some data rendering correctly and others throwing errors

I am currently developing an online magazine using React, similar to popular publications like Vogue and Elle. In my project, I have a JavaScript file that serves as an API for the data, containing an array of objects. Each object within the array represen ...

Utilizing Angularfire OAuth for Facebook authentication in login strategy

After successfully implementing the code below in the loginCtrl controller and login.html, I encountered some issues with setting up the workflow correctly. My goal is to achieve something like this: //check if the current $scope has authData //if so red ...

How come TinyMCE is showing HTML code instead of formatted text?

I have been working on integrating TinyMCE with React on the frontend and django(DRF) on the backend. After saving data from TinyMCE, it retains the HTML tags when displayed back, like this: <p>test</p> <div>Test inside div</div> ...

Triggering Submit Button Based on Checkbox Value in jQuery

Hey there, I'm encountering an issue. Let's say I have two types of checkboxes - one for person and one for company. If I submit the form without checking any of the person or company checkboxes, I want jQuery to display an alert. Otherwise, the ...

Manipulate JSON data structure with JavaScript

The initial JSON data: { "data": { "count_at_hub": [ { "hub": "A", "date": "", "size": "1", "count": 141 }, { "hub": "A", "date": "", "size": " ...

Is there a way to utilize two onChange functions within one component?

I'm having trouble utilizing two onChange functions within the same component. I attempted to combine them, but I ran into an issue because one is using useState and the other is a const function. Below is my code snippet: const signup = () => { ...

Error message: "Module not found - Electron application"

I've been working on developing an audio enhancer application using electron. However, whenever I click on the enhance button, I encounter this error in the console: (node:7587) UnhandledPromiseRejectionWarning: Error [ERR_MODULE_NOT_FOUND]: Cannot fi ...

retrieving elements from an array object results in an undefined value

Utilizing an API to retrieve holidays and their corresponding dates, I extracted values from a JSON file and organized them into an array of arrays. function getHolidays(){ (...) var ulHoliday = new Array(); var txt = JSON.parse(this.responseText); const h ...

An error occurred while trying to load the resource in the Redux-Saga: connection refused

Utilizing axios allows me to make calls to the backend server, while redux-saga helps in managing side effects from the server seamlessly. import {call, put, takeEvery} from "redux-saga/effects"; import {REQUEST_FAILED, REQUEST_SUCCESS, ROOT_URL, SUBMIT_U ...

Error encountered: No matching overload found for MUI styled TypeScript

I am encountering an issue: No overload matches this call. Looking for a solution to fix this problem. I am attempting to design a customized button. While I have successfully created the button, I am facing the aforementioned error. Below is my code ...

Tips for showcasing individual product information on your e-commerce site using React-js and React-Router-dom

As I work on developing an e-commerce platform, my goal is to create a functionality where users can view detailed information about a specific product by clicking on it. To achieve this, I am using React.js along with react-router-dom. Can anyone guide me ...

Tips for ASP.NET MVC Developers to Follow for Optimal Performance

Apologies for the question being so subjective. Seeking practical examples of effectively managing JavaScript in ASP.NET MVC applications. Prior to jQuery, I tended to avoid using JavaScript whenever possible. Now that I am utilizing it more frequently, ...

Learn the process of encoding a string in JavaScript or jQuery and then decoding it with PHP

I am facing an issue with updating a field in the database using Ajax and PHP. Everything runs smoothly except when there are special characters present, like this: اللهم اني اشكو اليك ضعف قوتي وقلة حيلتي وهواني عل ...

What is the process of converting the timing from my stopwatch to a standard time format?

I am currently working on a stopwatch project where I log the time into an array. However, when I try to use Math.min(array) or Math.max(array), it returns NaN (not a number). The time format for the stopwatch is like 00:00:15.91 which is not recognized as ...

Exploring the Fusion of Strings and Arrays of Javascript Objects using jQuery and JSON

Trying to achieve a simple task, but not very proficient in jQuery so struggling to figure it out. Want to send JSON data to an ASP.NET Controller. Data includes strings and a list of objects. The code snippet would appear like this: View: $(document). ...

Exploring the concepts of arc functions in discord/js programming

Example: Having trouble understanding how to create an arc in JavaScript based on a percentage input? Here's a simple explanation: feed it a percentage and it will create an arc that represents that percentage of a circle. I've managed to get t ...

When updating the location.hash property via a click event, it appears to be set to

Check out the code snippet below: $(e).click(function() { console.log(this.href); location.hash = this.href; }); In this code snippet, e refers to a <li> element structured like this: <li href="#about">About</li> The location. ...

Utilizing a URL to dynamically update the content within an I-Frame

One day, I made the questionable decision to use i-frames to load pages on my website in order to keep a sidebar on the main page without having to constantly make changes. In hindsight, I should have done the opposite and put the sidebar in the i-frame. N ...

Determining the True Width of a Div

I am working with a div that has a class of myid_templates_editor_canvas-selection. <div class="myid_templates_editor_canvas-selection" style="position: absolute; font-size: 0px; left: 0px; top: 0px; width: 377px; height: 174px;"></div> The w ...