In my SignalR Client I have the following javaScript libraries:
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.6.4.min.js"></script>
<!--Reference the SignalR library. -->
<script src="Scripts/jquery.signalR-2.2.1.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="http://localhost:8081/signalr/hubs"></script>
In the Javascript I go:
$.connection.hub.url = "http://localhost:8081/signalr;
$.connection.hub.logging = true;
var push = $.connection.exosChangeNotifier;
...
$.connection.hub.start().done();
The connection works well with localhost. When I run my SignalR hub on a VM or on another computer and replace localhost with the ip-address or the computer name, I get a
http://[servername]:8081/signalr/hubs Failed to load resource: the server responded with a status of 400 (Bad Request)
Uncaught TypeError: Cannot read property 'client' of undefined.
I opened up the port 8081 on the firewall on my computer as outgoing rule and as ingoing rule on the remote computer or the VM. With Sysinternal psping I verified that the port is reachable:
psping.exe [servername]:8081 -h
With a Powershell Script I was able to double check the computer is reachable and the port is open.
On the self-hosted SignalR Startup I have CORS enabled:
map.UseCors(CorsOptions.AllowAll);
What am I missing?
I found the solution in this SO Question. The server has to start as http://*:8081 to respond to internal and external requests. Before it was set to only listen to localhost.