Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR /signalr/hubs 404 Not Found

I am trying to deploy a SignalR site on IIS. Code all works fine in VS. But getting the 404 not found error trying to resolve signalr/hubs so far I have tried.

1) Changing the Script ref to:

script src="<%= ResolveUrl("~/signalr/hubs") %>" type="text/javascript"></script> 

2) Modifying Web.Config to include :

<system.webServer>     <validation validateIntegratedModeConfiguration="false" />     <modules runAllManagedModulesForAllRequests="true">     </modules> </system.webServer> 

3) Changing the invoke requests on IIS for UrlMappingsModule.

4) added SignalR.Hosting.AspNet.dll to see if that would help anything.

Not sure what else to try or check, any help or point in the right direction?

like image 442
user685590 Avatar asked Jun 22 '12 11:06

user685590


People also ask

How do I reconnect my SignalR?

Handle the disconnected event to display a message when an attempt to reconnect has timed out. In this scenario, the only way to re-establish a connection with the server again is to restart the SignalR connection by calling the Start method, which will create a new connection ID.

What is a SignalR hub?

What is a SignalR hub. The SignalR Hubs API enables you to call methods on connected clients from the server. In the server code, you define methods that are called by client. In the client code, you define methods that are called from the server.

Does SignalR need SSL?

If your SignalR application transmits sensitive information between the client and server, use SSL for the transport.


2 Answers

The order of route registration matters. I had this exact problem and fixed it by ensuring my global.asax.cs looked like this:

public class MvcApplication : System.Web.HttpApplication {     protected void Application_Start()     {         AreaRegistration.RegisterAllAreas();         RouteTable.Routes.MapHubs();          WebApiConfig.Register(GlobalConfiguration.Configuration);         FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);         RouteConfig.RegisterRoutes(RouteTable.Routes);     } } 

This was in a web site using SignalR, MVC and WebApi all together.

like image 69
SimonF Avatar answered Sep 17 '22 15:09

SimonF


The reason of this 404 error is hubs are not mapped, previously it would have to be done as answered by SimonF. If you are using SignalR version 2 RouteTable.Routes.MapHubs(); is now obsolete. For mapping hubs you can create a startup class as below.

[assembly: OwinStartup(typeof(WebApplication1.Startup))] namespace WebApplication1 {     public class Startup     {         public void Configuration(IAppBuilder app)         {             // Any connection or hub wire up and configuration should go here             app.MapSignalR();         }     } } 

referenace : http://www.asp.net/signalr/overview/releases/upgrading-signalr-1x-projects-to-20

like image 35
Chaitanya Gadkari Avatar answered Sep 20 '22 15:09

Chaitanya Gadkari