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

Viewed 3521

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.

1 Answers

Had the same error. In my case that was because of type mismatch. Server expected string. Client was sending value from variable with value '1234', that was sending as a int.

Related