How to fix “HTTP Error 400. The size of the request headers is too long” error from azure cloud services?

We are doing a load/performance test on our Azure cloud service, where we hosted Web APIs. After a certain number of calls (say 500), cloud service is giving bad request error.

We have built web APIs in c# using web role and hosted them in Azure cloud service. I went through a few articles/forums and tried a couple of options as mentioned below: 1. Tried increasing cloud service VM instance size. 2. Tried increasing ‘maxAllowedContentLength’ value to 52428800. 3. Tried increasing ‘maxRequestLength’ value from 5120 to 16240. 4. Used VS Diagnostic tool to check if the issue is because of memory leak. None of them worked.

After hitting endpoint for around 450 – 500 times, this error comes only comes from the endpoints which involve communication to subsystems. This error is not reproducible locally. To come out of this problem, either we have to redeploy the cloud service or restart the cloud service. Ideally, cloud service should work until it’s resource consumption reaches 100%. But getting below error after every approx 500 calls with max 10 – 15% resource utilization.

<HTML>
<HEAD>
<TITLE>Bad Request</TITLE> 
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD> 
<BODY>
<h2>Bad Request - Request Too Long</h2> 
<hr><p>HTTP Error 400. The size of the request headers is too long.</p> 
</BODY>
</HTML>

Leave a Comment