signalRJS icon indicating copy to clipboard operation
signalRJS copied to clipboard

Unable to respond to the HubProxy using broadcast without error

Open BaptisteDegryse opened this issue 7 years ago • 0 comments

I have a problem returning a value after a client to server hub call using HubProxy. You can find a minimalist sample of the bug attached to this issue. The client receive the result "broadcast", but it throws an exception, and the next broadcast calls will not complete.

The Client should remain unchanged since it is used with other servers (in C#) and is already working well.

It has been 2 days that I'm trying to find a solution (and fork the repo), but I am still searching... Any help would be really appreciated :)

On the client side:

     $(function () {
            var connection = $.hubConnection("serverwebsite");
            var hubProxy = connection.createHubProxy("serverwebsite");
            console.log(hubProxy);
            connection.start().done(function() {
                hubProxy.invoke("GetConnectedServices").done(result => {
                        console.log(result);
                    });
            });
        });

On the server side:

    var signalR = signalRJS();
    signalR.route = "/serverwebsite/signalr";
    this.express.use(signalR.createListener());
    signalR.hub('serverwebsite', {
      "GetConnectedServices": function () {
        console.log("GetConnectedServices! ");
        signalR.broadcast({ R: "broadcast" , I:0});
      }

    })
    signalR.on('CONNECTED', function () {
      console.log("connected");
    });

BugSignalrjs.zip

BaptisteDegryse avatar Mar 07 '18 12:03 BaptisteDegryse