Better handling of EWS throttling
OS: ArchLinux (rolling)
Evolution Versions: evolution 3.46.1 / evolution-data-server 3.46.1 / evolution-ews 3.46.1
Email Server: Office365 (outlook.office365.com)
Protocol: EWS (OAuth2)
Pre-requisites:
- An Office365 account with a lot of email (say more than 30,000 emails)
- Add Office365 account with EWS (OAuth2) per the instructions here
Scenario: Evolution begins to synchronise the emails/calendar/etc. from the Office365 account, but the Office365 EWS throttling is not handled properly. Once the throttle limits are reached, Office365 returns a HTTP/500 response. Part of that message includes a "Back Off" duration (called BackOffMilliseconds). Within this "back off" duration, any additional requests result in a HTTP/500 response. During this "back off" period, Evolution displays this error dialogue , which has no real information about the reason for error. Also, Evolution continues to attempt to synchronise the emails during the "back off" period instead of waiting for the throttle limit to be reset.
Debug Messages:
> POST /EWS/Exchange.asmx HTTP/1.1
> Soup-Debug-Timestamp: 1667419513
> Soup-Debug: ESoupSession 1 (0x558f392316a0), SoupMessage 628 (0x558f39b40ca0), GSocket 628 (0x7fe3b0011130)
> Cache-Control: no-cache
> Pragma: no-cache
> Content-Type: text/xml; charset=utf-8
> Content-Length: 1015
> User-Agent: Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.15225; Pro)
> Connection: Keep-Alive
> Accept-Encoding: gzip, deflate, br
> Accept-Language: en
> Host: <redacted>
> Cookie: <redacted>
> Authorization: <redacted>
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><types:RequestServerVersion xmlns:types="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2013"/></SOAP-ENV:Header><SOAP-ENV:Body xmlns:messages="http://schemas.microsoft.com/exchange/services/2006/messages"><messages:SyncFolderItems xmlns="http://schemas.microsoft.com/exchange/services/2006/types"><messages:ItemShape><BaseShape>IdOnly</BaseShape></messages:ItemShape><messages:SyncFolderId><FolderId Id="AAMkADRjYmEyNjkyLWVhNDEtNDZiYy1hMTUyLWJjMzM2YjJhN2E5OQAuAAAAAABnEaKSQ8knQp247+6KONJQAQD/C4fh+O9tRJyIXlwYr8nyAAAnfDRAAAA="/></messages:SyncFolderId><messages:MaxChangesReturned>100</messages:MaxChangesReturned></messages:SyncFolderItems></SOAP-ENV:Body></SOAP-ENV:Envelope>
< HTTP/1.1 500
< Soup-Debug-Timestamp: 1667419513
< Soup-Debug: SoupMessage 628 (0x558f39b40ca0)
< Cache-Control: private
< Content-Length: 810
< Content-Type: text/xml; charset=utf-8
< Server: Microsoft-IIS/10.0
< Set-Cookie: <redacted>
< Date: Wed, 02 Nov 2022 20:05:13 GMT
< request-id: dedc880e-f85e-c2bf-dc0f-178731ef40eb
< Alt-Svc: h3=":443",h3-29=":443"
< X-CalculatedFETarget: AM0PR10CU003.internal.outlook.com
< X-BackEndHttpStatus: 500
< X-CalculatedBETarget: AM0PR05MB6705.eurprd05.PROD.OUTLOOK.COM
< X-BackEndHttpStatus: 500
< X-RUM-Validated: 1
< x-ms-appId: 895efcb4-f7bf-4a7f-a42b-af904d5fca59
< Restrict-Access-Confirm: 1
< X-AspNet-Version: 4.0.30319
< X-BeSku: WCS6
< X-DiagInfo: AM0PR05MB6705
< X-BEServer: AM0PR05MB6705
< X-Proxy-RoutingCorrectness: 1
< X-Proxy-BackendServerStatus: 500
< X-FEProxyInfo: PH0PR07CA0057.NAMPRD07.PROD.OUTLOOK.COM
< X-FEEFZInfo: PHX
< X-FEServer: AM0PR10CA0075
< X-FirstHopCafeEFZ: PHX
< X-Powered-By: ASP.NET
< X-FEServer: PH0PR07CA0057
<
< <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorServerBusy</faultcode><faultstring xml:lang="en-US">The server cannot service this request right now. Try again later.</faultstring><detail><e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorServerBusy</e:ResponseCode><e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The server cannot service this request right now. Try again later.</e:Message><t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><t:Value Name="BackOffMilliseconds">296999</t:Value></t:MessageXml></detail></s:Fault></s:Body></s:Envelope>
(evolution:59144): camel-ews-provider-WARNING **: 13:07:14.449: Unable to fetch the folder hierarchy: :500
Expected: Evolution will synchronise the emails from the Office365 account, while handling the Office365 EWS throttling by displaying better error messages, as well as respecting the throttle back-off window