locked
Uncaught (in promise) Error: Failed to invoke 'XXXXX' due to an error on the server RRS feed

  • Question

  • User445468845 posted

    I created a .net core chat application using SignalR and I used WebRTC for video calls. As I need to send the SDP to the receiver using server method so I created a hub method call "SendOffer". When I click Video call button I have invoked this "SendOffer" method. I have put the client side code below

    var connection = new signalR.HubConnectionBuilder()
        .withUrl('/chat')
        .build();
    
    const Peer = new RTCPeerConnection();
    
    const video = document.querySelector('video');
    
    const constraints = {
        'video': true,
        'audio': true
    }
    
    document.getElementById("sendVideo").addEventListener("click", function (event) {
    
        navigator.mediaDevices.getUserMedia({
            video: true,
            audio: true,
        }).then(function (stream) {
            video.srcObject = stream
            video.play();
            //Peer.addStream(stream);
            Peer.createOffer()
                .then(sdp => Peer.setLocalDescription(sdp))
                .then(function () {
                    console.log(Peer.localDescription);
                    //connection.invoke("SendOffer", Peer.localDescription).catch(function (err) {
                    //    return console.error(err.toString());
                    connection.invoke("SendOffer", Peer.localDescription);
                })
        });
    })

    But this gives an error in the console log and not working. blow is the error

    signalr.js:2088 Uncaught (in promise) Error: Failed to invoke 'SendOffer' due to an error on the server. at _this.callbacks. (signalr.js:2088) at HubConnection.processIncomingData (signalr.js:2182) at WebSocketTransport.HubConnection.connection.onreceive (signalr.js:1905) at WebSocket.webSocket.onmessage (signalr.js:3949)

    Can any one please help me to solve this error.

    Sunday, April 5, 2020 9:47 PM

All replies

  • User711641945 posted

    Hi Janitha,

    The error message indicates that your server side makes error.Could you show error logs which is on your server side?

    Best Regards,

    Rena

    Monday, April 6, 2020 9:37 AM
  • User445468845 posted

    Hi Rena

    the last part I have mention in the question is the error log that was given. But unfortunately I cant get the error back as code start to work correctly.  

    function CreatePeer() {   

            alert("Enter in to MakePeer");

            client.gotAnswer = false;

           let peer = InitPeer('init');

          // let data = null;</div> <div>           

           peer.on('signal', function (data) { 

                 if (!client.gotAnswer) {

                          connection.invoke('SendOffer', data);

                            alert(JSON.stringify(data));

                  }   

    });

    client.peer = peer;

    }

    This was the code. when the pointer is in  "connection.invoke('SendOffer', data);"  this error was given.  So I call this part under the "let data =null". Then It was successfully run. I did it because in the error I saw websoket is received . But the guess makes the code right. But I don't have exact Idea why this happen. As you ask the console log I run the code keeping it as same above to take the error but now it is working. I think at that time some thing blocking must be happen.If you know can can you explain me and thanks for your reply 

    Tuesday, April 7, 2020 8:56 PM