SignalR Negotiate 404 on a subdomain
I created a small MVC SignalR application that I was crashing on my server under a subdomain: http://chat.mydomain.com which shows up in a folder named / chat.
I also created a console program using SignalR Client that connects and works fine, oddly enough.
The MVC application error is 404 from http://chat.mydomain.com/chat/signalr/negotiate?clientProtocol= [...] . I understand why this is happening, but I don't know how to fix it. In my generated hubs file, the line
signalR.hub = $.hubConnection("/chat/signalr", { useDefaultPath: false });
technically correct but must read $.hubConnection("/signalr", { useDefaultPath: false });
Any ideas on how to change this? Or should I just use the original connection API.
And why does it work correctly from a console application?
Thanks in advance.
source to share
You can continue to use the generated hubs file. You just need to change the hubConnection url (which is stored in $.connection.hub.url
) before you start connecting to SignalR.
// This is initially set to "/chat/signalr" as specified in the hubs file
$.connection.hub.url = "/signalr";
$.connection.hub.start()...
source to share