iPhone, Android, Windows Phone high data usage due to "Exception message: Maximum request length exceeded"

by Ed Sparks

A significant flaw exists in the design of Exchange ActiveSync, in our opinion, in that most mobile devices - particularly the iPhone - will leave a large message stuck in the outbox and continuously try to resend the message over and over without limit until the user deletes the message.

This issue is most commonly caused by the default IIS configuration on Exchange CAS servers that limits incoming messages to about 4-10MB in size (depending on version) - regardless of the limits set elsewhere in the Exchange organizational or user configurations.  You will know this is the problem if you see the following event frequently in your Exchange CAS Application event logs:

EVENT LOG Application
EVENT TYPE Warning
SOURCE    MSExchange ActiveSync
EVENT ID  1008
MESSAGE
An exception occurred and was handled by Exchange ActiveSync. This may have been caused by an outdated or corrupted Exchange ActiveSync device partnership. This can occur if a user tries to modify the same item from multiple computers. If this is the case, Exchange ActiveSync will re-create the partnership with the device. Items will be updated at the next synchronization.
URL=/Microsoft-Server-ActiveSync/default.eas?Cmd=SendMail&DeviceId=3939303030313138343433383037&DeviceType=iPhone4S&SaveInSent=T
--- Exception start ---
Exception type: System.Web.HttpException
Exception message: Maximum request length exceeded.
Exception level: 0
Exception stack trace: at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.get_InputStream()
at Microsoft.Exchange.AirSync.Command.get_InputStream()
at Microsoft.Exchange.AirSync.Command.WorkerThread()
--- Exception end ---.
on message: Maximum request length exceeded.
Exception level: 0
Exception stack trace: at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.get_InputStream()
at Microsoft.Exchange.AirSync.Command.get_InputStream()
at Microsoft.Exchange.AirSync.Command.WorkerThread()
--- Exception end ---

Not only does this cause a poor end-user experience, it can also cause very high data usage that can be costly.  Imagine a 20 or 30 MB message getting submitted hundreds of times from the device until the user notices!  The design flaw means that entire 30MB gets uploaded to the server every time before getting rejected.

Thankfully, there is a relatively easy - though non-obvious - solution that we always enable at our client sites.  

  1. On your CAS server, navigate to your Exchange program folders.  i.e. on 2010 - C:\Program Files\Microsoft\Exchange Server\V14\ClientAccess\Sync
  2. Make a copy of the existing web.config file as a backup
  3. Open the web.config file and look for the entry 
     <httpRuntime maxRequestLength=”10240″/>  
  4. Change the entry to a much larger number.  We recommend 50MB, of an entry of 51200 in order that this limit is never hit.  
  5. Save the file.  
  6. Normally you don't need to restart IIS as web.config changes are picked up automatically, but you can run iisreset /noforce /timeout:200 for good measure.

This allows for large attachments to still make it through from the device, and then hit your actual Exchange-based attachment limits where the user will get a normal rejection message instead of just getting stuck on the device and chewing up all your data.