1

I have an ASP.NET MVC 4 website that uses Mini Profiler. Just recently I've started using SignalR for the more interactive pages.

I've got an issue with the SignalR pages when they're open a long time. Mini Profiler frequently generates an arithmetic overflow error because of the large amount of time that the SignalR request has been open. I understand that it's possible for Mini Profiler to ignore SignalR requests MVC Mini Profiler Exception on MiniProfiler.Stop() .

However I'm still keen to analyse the performance of my individual SignalR actions within a request using Mini Profiler. Is there any way to do this?

Community
  • 1
  • 1
Giles Roberts
  • 6,407
  • 6
  • 48
  • 63
  • are there certain SingalR requests that always stay open a while and some that dont? Or it could be any? – Yaakov Ellis Apr 29 '14 at 06:12
  • @YaakovEllis Some SignalR requests are short lived. The main one is a persistent connection. What I'd be interested in is collecting performance data on the sub-requests that happen inside the main persistent connection. – Giles Roberts Apr 29 '14 at 08:10

1 Answers1

1

The default way in which MiniProfiler is run is to call Start() at the beginning of your request, which initializes a MiniProfiler instance to collect your Timings. Then call Stop() at the end of the request, which will record your timings.

In your case you cant do this because the request goes on for too long. But you still want to record timings for individual actions within the one overall SignalR request.

In this model, your actions are really more equivalent to what we would consider to be normal http requests in a web application. So a solution that might work for you would be to run MiniProfiler.Start() at the beginning of each of these actions, and MiniProfiler.Stop() at the end of each of these, treating each as its own end-to-end unit (and saving profile info whenever you call Stop()).

Start Main SignalR Connection

  SignalR Request Action1
    MiniProfiler.Start()
    Perform Action
    MiniProfiler.Stop()
  End SignalR Request Action1

  SignalR Request Action2
    MiniProfiler.Start()
    Perform Action
    MiniProfiler.Stop()
  End SignalR Request Action2

  ... Many More Actions ...

End Main SignalR Connection
Yaakov Ellis
  • 40,752
  • 27
  • 129
  • 174
  • Thanks for the response. In my case calling MiniProfiler.Stop() in the SignalR hub action doesn't appear to be saving the profile info. Generally I'm saving my MiniProfiler results to my database for analysis. The SignalR hub actions don't appear either in the UI, which I'm not surprised about and don't really care about, or in the database. Is my question actually a different question, namely how do you get MiniProfiler to record non UI tasks? – Giles Roberts May 01 '14 at 07:03
  • On further investigation it seems that my problem is my MiniProfiler.Current is null in the SignalR hub classes so the start and stopping is having no effect. I'm just looking into setting up the correct context for this. – Giles Roberts Jun 10 '14 at 10:27