Azure HTTP timeouts
An avid reader of my blog pointed me towards this post, which suggests that Azure will time out your incoming requests after a minute.
I constructed a quick test in MVC, which would block the server for a number of miliseconds before returning:
public ActionResult Index(int duration)
{
System.Threading.Thread.Sleep(duration);
return Content(string.Format("Response after {0}ms wait", duration));
}
I passed in variety of durations, and found that anything under 4 minutes (240000 ms) worked, and over 4 minutes didn’t.
Trying the same test with IE on the VM (using the local ip address) and thus not going through the load balancer resulted in much higher times I didn’t have the patience to find out exactly how long.
We can conclude that something in the Azure infrastructure (like the firewall or load balancer) is terminating HTTP requests after 4 minutes (my reader confirms this too).
It’s not uncommon for network infrastructure (which could be anywhere between you and the cloud) to terminate HTTP connections after 1 minute or 2, so your code shouldn’t try and block for this long anyway.



vbmagic 10:31 am on March 5, 2012 Permalink | Log in to Reply
It would be interesting to see if you get the same time-outs when using a non windows web server such as jBoss/Apache
Richard 11:38 am on March 5, 2012 Permalink | Log in to Reply
It should be exactly the same (unless the alternative server closes the connection earlier) as it’s the Azure infrastructure which is closing the connection. Worth trying though!
vbmagic 11:57 am on March 5, 2012 Permalink | Log in to Reply
I was wondering if its a feature of IIS that exists in Azure compute role (Different to the IIS that runs in the Server 2008 (R2) ) or like you said the azure infrastructure.
Richard 12:08 pm on March 5, 2012 Permalink | Log in to Reply
Good question. I did all of my testing from inside Azure. Some requests I sent via the load balancer, by using the *.cloudapp.net address, other requests I made directly by using the machine’s internal IP address. When I went via the NLB, it timed out after 4 minutes. Otherwise the requests lasted a lot longer.
Having said all of this, some people are experiencing longer timeouts, and I’m not sure why.