In the end I think that in my case the problem was that my development machine had a lot of stuff installed on it (VS 2010, .NET 1.0 - 4.5 and heaps of other development environements nd libraries), then I installed Windows 8 Preview, which led to the system
being confused about whether it had .NET 4.5/4.0 or 3.5 installed on it. My machine was a bit of a mess and needed a rebuild.
Still, I would have preferred to get to the bottom of it.
Ok, I can reproduce the issue. My current environment is win7 64, vs2012, iis express, .net 4.5.
I've followed your instructions and have found where it is choking at. Indeed, it is the PerformanceCounterManager class. The particular method is below:
private static bool PerformanceCounterExistsSlow(string categoryName, string counterName)
{
// Fire this off on an separate thread
var task = Task.Factory.StartNew(() => PerformanceCounterExists(categoryName, counterName));
if (!task.Wait(_performanceCounterWaitTimeout))
{
// If it timed out then throw
throw new OperationCanceledException();
}
return task.Result;
}
I'm hitting the OperationCanceledException nearly every time. If I break on that exception or step through the method than iis express will happily continue and everything seems to work fine. If I don't break on that exception, I will see [A first chance
exception of type 'System.OperationCanceledException' occurred in Microsoft.AspNet.SignalR.Core.dll] in the debug output and iis express hangs.
Essentially, if I slow down the execution with some breakpoints than the hanging problem dissapears (still throws OpCancelException, but continues).... wierd!
If i change the hardcoded value of _performanceCounterWaitTimeout from "TimeSpan.FromSeconds(2);" to something higher than the exception is never thrown to begin with.
I get this issue only when running signalR in a webrole via the azure compute emulator. it works ok when i take the same project and run it in a non azure context.
Not sure if this helps, but I'm running into the same issue in an MVC 4 application. If I move the RouteTable.Routes.MapHubs(); line out of Global.asax and put it in my RoutConfig.RegisterRoutes method, the problem goes away. However, the problem now is
that the hubs are being mapped AFTER my WebAPI routes are registered and Areas are registered. This isn't an issue for me since I don't plan on adding any api's or areas that will override the signalr route. I do find it odd though that moving it to the
RouteConfig fixes the probem. I can reproduce the issue by moving it back to the application start and fix it again by moving it back to RouteConfig. Here's my test RegisterRoutes method... and SignalR still works just fine.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
RouteTable.Routes.MapHubs();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Putting MapHubs first or last has nothing to do with this problem. The 2 things are completely unrelated. The fact that you have to put MapHubs before the MVC route is explicitly called out in the documentation under the FAQ section
https://github.com/SignalR/SignalR/wiki/Faq.
jamesbdarcy
0 Points
8 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Jan 24, 2013 04:33 AM|LINK
In the end I think that in my case the problem was that my development machine had a lot of stuff installed on it (VS 2010, .NET 1.0 - 4.5 and heaps of other development environements nd libraries), then I installed Windows 8 Preview, which led to the system being confused about whether it had .NET 4.5/4.0 or 3.5 installed on it. My machine was a bit of a mess and needed a rebuild.
Still, I would have preferred to get to the bottom of it.
davidfowl
Contributor
2695 Points
609 Posts
Microsoft
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Jan 28, 2013 09:13 AM|LINK
If anybody can reproduce this let me know.
Senior SDE, ASP.NET Team, Microsoft
bytenik
Member
8 Points
4 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Jan 28, 2013 12:19 PM|LINK
I can reproduce this, but only on one of my two dev boxes.
flavorful
Member
94 Points
22 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Jan 30, 2013 04:52 AM|LINK
Ok, I can reproduce the issue. My current environment is win7 64, vs2012, iis express, .net 4.5.
I've followed your instructions and have found where it is choking at. Indeed, it is the PerformanceCounterManager class. The particular method is below:
private static bool PerformanceCounterExistsSlow(string categoryName, string counterName) { // Fire this off on an separate thread var task = Task.Factory.StartNew(() => PerformanceCounterExists(categoryName, counterName)); if (!task.Wait(_performanceCounterWaitTimeout)) { // If it timed out then throw throw new OperationCanceledException(); } return task.Result; }I'm hitting the OperationCanceledException nearly every time. If I break on that exception or step through the method than iis express will happily continue and everything seems to work fine. If I don't break on that exception, I will see [A first chance exception of type 'System.OperationCanceledException' occurred in Microsoft.AspNet.SignalR.Core.dll] in the debug output and iis express hangs.
Essentially, if I slow down the execution with some breakpoints than the hanging problem dissapears (still throws OpCancelException, but continues).... wierd!
If i change the hardcoded value of _performanceCounterWaitTimeout from "TimeSpan.FromSeconds(2);" to something higher than the exception is never thrown to begin with.
I hope this helps.
3s-o
Member
2 Points
1 Post
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 01, 2013 06:59 AM|LINK
I get this issue only when running signalR in a webrole via the azure compute emulator. it works ok when i take the same project and run it in a non azure context.
Hope this is somehow helpful info.
bytenik
Member
8 Points
4 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 01, 2013 11:21 AM|LINK
Seems to happen in both contexts for me.
dhorne41
Member
15 Points
9 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 04, 2013 08:52 PM|LINK
Not sure if this helps, but I'm running into the same issue in an MVC 4 application. If I move the RouteTable.Routes.MapHubs(); line out of Global.asax and put it in my RoutConfig.RegisterRoutes method, the problem goes away. However, the problem now is that the hubs are being mapped AFTER my WebAPI routes are registered and Areas are registered. This isn't an issue for me since I don't plan on adding any api's or areas that will override the signalr route. I do find it odd though that moving it to the RouteConfig fixes the probem. I can reproduce the issue by moving it back to the application start and fix it again by moving it back to RouteConfig. Here's my test RegisterRoutes method... and SignalR still works just fine.
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); RouteTable.Routes.MapHubs(); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }Sona.ar
Member
77 Points
30 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 07, 2013 09:17 AM|LINK
Hey dhorne41
think you are right.. when we create simple web app and add MapHubs method at Routetable’s collection, it works smoothly.
However for MVC as there are already some route methods called on the same route collection in
public static void RegisterRoutes(RouteCollection routes)
MapHubs does not work in the similar manner.
I was getting same errors at run time like callback dynamic methods not found, Hubs.js not getting generated n all.
I moved RouteTable.Routes.MapHubs() before RegisterRoutes(RouteTable.Routes) call and simple chat application started working.
Now I have to really see if anything else in MVC gets faulty because of this or not.
davidfowl
Contributor
2695 Points
609 Posts
Microsoft
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 07, 2013 04:35 PM|LINK
Putting MapHubs first or last has nothing to do with this problem. The 2 things are completely unrelated. The fact that you have to put MapHubs before the MVC route is explicitly called out in the documentation under the FAQ section https://github.com/SignalR/SignalR/wiki/Faq.
Senior SDE, ASP.NET Team, Microsoft
bytenik
Member
8 Points
4 Posts
Re: Call to RouteTable.Routes.MapHubs() crashing IIS
Feb 21, 2013 12:05 PM|LINK
Is this issue still being looked at? It has become a significant blocker that half of my dev team cannot launch our web project.