3

I have a problem when running an MVC4 website from my visual studio debugger, if there are too many pages open, the ajax request takes a very long time to begin sending. The very strange thing is that if I close one of the pages, the request will start immediately.

More details... Framework: MVC 4 IDE: Visual Studio 2010 Browser: IE 9/Chrome

Controller:

[Authorize]
[SessionState(SessionStateBehavior.Disabled)]
public class AnalyticsController 
    : Controller
{        
    public ActionResult SaveWorkspace( Workspace model)
    {
        var returnVal = _save(model);
        return Json(new { actionResult = returnVal, messages = new string[] {} } );
    }
}

I have tried this with both an AsyncController and inheriting from Controller with the same results.

Client:

$.ajax({
    url: '/Analytics/SaveWorkspace',
    type: "POST",
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(workspace),
    success: function (result) {
        alert("Function Executed");
    }
});

Above is the ajax call I use. What I do is click various links on my web page which will open new windows. For my test, I opened the initial browser from my debugger and from my main page I spawned 5 other browsers. The call above executes immediately from the window started by my debugger but when I view the request from the network capture it will sit saying "Pending" until it eventually timed-out.

Now the interesting part is that if I close any one of those windows I spawned, the request will change from pending and go to my controller and return as expected. With a little more playing around, if I try it again (not opening additional browsers) it will always get sent to the server immediately, but if I open that 5th browser, then it becomes slow again. I did various tests to make sure nothing was wrong with specific windows, it seems to be that magic number of 5 browsers that causes my request to not be sent.

Here is a screenshot of my successful request when I close the 5th browser window. Success

Here is a capture of my request headers enter image description here

Here is a capture of my response headers enter image description here

Here is a capture of my timings enter image description here

The main thing I can't really understand is why there is a 46 second wait period and then two start periods. It seems the first start period was the long one, and the second start happened when I closed my 5th browser window.

I tried to provide as much detail as possible along with data to help diagnose what is going on. If there is anything else I can do to paint a better picture, feel free to post a comment. Any suggestions will be more than welcome.

Thank you all!

mvcNewbie
  • 520
  • 1
  • 11
  • 23
  • You haven't really explained what this `_save(model)` method is actually doing in your controller action. In order to further debug this issue I would start by dummyfying the controller action further and getting rid of this `_save` call. Can you observe the same behavior now? If not, then it is obvious that the problem is in this `_save` method. If yes, then, well, it's pretty weird. Also how can you possibly use IE to do web development? Try using a web browser, not IE. – Darin Dimitrov Aug 01 '13 at 20:47
  • I don't believe it is the _save(model) because it's not even making it to this point since the request is pending. If I were to remove this code, I still get the same issue. – mvcNewbie Aug 01 '13 at 21:07

3 Answers3

2

You might be hitting the limit on the maximum number of connections to a single domain, which is 6 in IE8. (See here for details.) I'm not sure about IE9, but as there hasn't been a press release about it I would assume it hasn't changed. It is also 6 in Chrome, according to this SO post. Do your 6 browser windows have any long-running requests open, which might be blocking the 7th ajax call?

The same SO post says that the connection limit is 8 in Firefox, so perhaps you could try running the application in that and seeing whether the problem still exists.

Community
  • 1
  • 1
Polly Shaw
  • 2,932
  • 1
  • 15
  • 21
  • Thank you so much for the input Polly, you hit the nail on the head for this issue. Now that I know what the problem is, it has become evident in my code on how to handle this issue. Thanks again! – mvcNewbie Aug 01 '13 at 21:33
0

I see following reason: you have breakpoint somewhere in the code. Probably it is in JavaScript (after you close browser request go immediately). So disable your breakpoints or if it won't help try to pause debugger to see what's going on.

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
0

I know of a problem with IE 8 debugging and I don't know if it also applies to IE 9, but it's also related to multiple open windows/tabs. Give it a try.

thmshd
  • 5,729
  • 3
  • 39
  • 67