Asked by:
SignalR application doesn't work on different computers/connections on the same URL

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
-
User61956409 posted
Hi johnyanovich,
Welcome to ASP.NET forums.
This works for multiple computers I've tried on each machine. But it does not update for other connections/computers.I checked the code that you provided, but not find something wrong with the code snippet. As you said, it does not work well on a specific computer, please check whether there are any errors in browser F12 developer tools Console tab.
Besides, [SignalR Tracing](https://docs.microsoft.com/en-us/aspnet/signalr/overview/testing-and-debugging/enabling-signalr-tracing) enables us to view diagnostic information about events in SignalR application, which would help troubleshoot the issue, you can try it.
$.connection.hub.logging = true;
With Regards,
Fei Han
Friday, May 17, 2019 1:42 AM -
User-931552316 posted
It is not that a specific computer does not work, but that it does not work between different computers. It works between different browsers or different tabs on the same computer. I thought I had to do something like this: (https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/real-time-web-applications-with-signalr#Exercise2) but the two computers in this case are on the same server, and are physically in the same location.
I get no errors at all through different logging methods, but I will look into and implement the tracking that you have linked. Thank you!
Friday, May 17, 2019 1:50 AM -
User61956409 posted
Hi johnyanovich,
It is not that a specific computer does not work, but that it does not work between different computers. It works between different browsers or different tabs on the same computer. I thought I had to do something like this: (https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/real-time-web-applications-with-signalr#Exercise2)If you are hosting your SignalR application on a server farm, you need to achieve Scaleout.
https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-in-signalr
With Regards,
Fei Han
Friday, May 17, 2019 2:24 AM