3

I've created a small MVC SignalR app which I'm having trouble running on my server under a subdomain: http://chat.mydomain.com, which maps to a folder called /chat.

I've also made a console program using SignalR Client which connects and works perfectly, strangely enough.

The error from the MVC app is a 404 from http://chat.mydomain.com/chat/signalr/negotiate?clientProtocol=[...]. I can see why this is happening but have no idea how to fix it. In my generated hubs file, the line

signalR.hub = $.hubConnection("/chat/signalr", { useDefaultPath: false });

is technically correct, but should read $.hubConnection("/signalr", { useDefaultPath: false });

Any ideas on how to alter this? Or should I just use the raw connection API.

Also why does it work properly from the console app?

Thanks in advance.

aligray
  • 2,812
  • 4
  • 26
  • 35

1 Answers1

4

You can continue to use the generated hubs file. You just need to modify the hubConnection's url (which stored at $.connection.hub.url) before you start your SignalR connection.

// This is initially set to "/chat/signalr" as specified in the hubs file
$.connection.hub.url = "/signalr";
$.connection.hub.start()...
jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
halter73
  • 15,059
  • 3
  • 49
  • 60
  • 1
    Cheers for your answer, I tried quite a few different urls before enabling deciding to enable jsonp and using _'//mydomain.com/chat/signalr'_ as the url and it worked! It feels a bit hacky doing it this way but at least it works! – aligray Nov 13 '14 at 04:13