locked
SignalR application doesn't work on different computers/connections on the same URL RRS feed

  • Question

  • User-931552316 posted

    So this is part of a bigger project, and I have posted a small test I created for the purpose of describing my problem. It work fine on one computer on multiple browsers (same or different browsers). But it does not work between different computers. I think perhaps I am misunderstanding how SignalR works and am making a stupid mistake, because I am stumped!

    Startup.cs:

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }

    Hub:

    public class VBMDataHub : Hub
    {
        public override Task OnConnected()
        {
            Clients.Others.broadcastConnected();
            return base.OnConnected();
        }
    }

    Javascript:

    var conn = $.connection.vBMDataHub;
    
    //SIGNALR START
    $.connection.hub.start();
    
    conn.client.broadcastConnected = function () {
        console.log("ANOTHER USER HAS JUST CONNECTED");
    };

    Now all this does is, when someone has entered that page, it sends a console message to everyone else. So for example if I open my page in Chrome, and then open another tab and go to the same url, the first page will get that message. And if I refresh either one, the other one should get the message.

    This works for multiple computers I've tried on each machine. But it does not update for other connections/computers.

    I apologize if this is a really silly thing I overlooked while reading the tutorial. I feel like maybe I'm doing something completely wrong and misunderstanding how signalR works.

    Some additional info on how I am using this: I am deploying to a shared dev server, so the two computers would be on the same server, right next to each other. 

    Thursday, May 16, 2019 11:14 PM

All replies