Handling notification-related errors in EWS in Exchange
Find out how to handle notification-related errors in applications that you develop by using the EWS Managed API or EWS in Exchange.
If your application subscribes to and gets notifications, you might have to handle notification-related errors. You can handle these errors at runtime, or while you are developing your EWS application.
Table 1. Notification-related errors and how to handle them
Error | Occurs when you try to… | Handle it by… |
---|---|---|
ErrorExceededConnectionCount | Open a connection to get events when the account reached its connection limit of open streaming connections. |
|
ErrorExceededSubscriptionCount | Create too many subscriptions. The EwsMaxSubscriptions throttling policy parameter determines the maximum number of subscriptions that an account can create. |
|
ErrorInvalidSubscriptionRequest | Create subscriptions for multiple mailboxes or multiple folders from a single request. | Creating a subscription for a single public folder or a single mailbox in a single request. |
ErrorInvalidWatermark | Get events by using an invalid watermark. |
|
ErrorMissedNotificationEvents | Get events when some previous events were missed. | Comparing the extended folder properties PR_LOCAL_COMMIT_TIME_MAX (0x670a) and PR_DELETED_COUNT_TOTAL (0x670b) to determine what changes were missed, and creating a new subscription. |
ErrorProxyRequestNotAllowed | Subscribe to events for a user in a batched request whose mailbox has moved to another site. | Using Autodiscover to rediscover the ExternalEwsUrl or EwsPartnerUrl, and creating a new subscription. |
ErrorReadEventsFailed | Get events from a subscription that cannot be found. | Using Autodiscover to rediscover the ExternalEwsUrl or EwsPartnerUrl, and creating a new subscription. |
ErrorServerBusy | Exceed throttling limits. Be aware of the following regarding throttling:
|
|
ErrorSubscriptionNotFound | Get events for a subscription that cannot be found. The subscription might have expired, the EWS process might have been restarted, or an invalid subscription was passed in. |
|
ServiceLocalException | Add a subscription to a new folder while a subscription connection is open on another folder. | Changing your subscription to subscribe to all folders in the mailbox, instead of a specific folder. |
ServiceResponseException | Get events for a subscription that cannot be located in the Exchange store. |
|
Recovering from lost subscriptions
When a subscription is lost, or is no longer accessible, it is best to create a new subscription and not include the old watermark in the new subscription. Resubscribing with the old watermark causes a linear scan for events, which is costly. Instead, create a new subscription and compare folder properties to look for content changes that occurred between the lost subscription and the new subscription. The extended folder properties that we recommend that you check are PR_LOCAL_COMMIT_TIME_MAX (0x670a0040) and PR_DELETED_COUNT_TOTAL (0x670b0003). You can do this by creating an extended property definition.