Yashi
Yashi

Reputation: 21

EWS API Streaming subscription stops working

Created an windows service which saves all received and sent emails to my local drive and my service successfully does that.I have also resubscribed my streaming subscription onDisconnect event and Onerror event also.But my service stops responding after some time and there is no exception catched even though i have handled everything properly.Saw other forum and found the same issue people facing but there is not proper solution.

 static private void OnDisconnect(object sender, SubscriptionErrorEventArgs args)
        {
            try
            {


                // Cast the sender as a StreamingSubscriptionConnection object.  

                StreamingSubscriptionConnection connection = (StreamingSubscriptionConnection)sender;
                if (!connection.IsOpen)
                    connection.Open();


        }


 static void OnError(object sender, SubscriptionErrorEventArgs args)
        {


                // Cast the sender as a StreamingSubscriptionConnection object.
                StreamingSubscriptionConnection connection = (StreamingSubscriptionConnection)sender;
                if (!connection.IsOpen)
                    connection.Open();


        }

Is this something to do with the Microsoft bug or it requires any settings on Exchange server for changing the limits for EWS subscription.

Even i checked below something related to throttling limit but no success: http://msdn.microsoft.com/en-us/library/exchange/hh881884(v=exchg.140).aspx

Thanks a million in advance.

Upvotes: 2

Views: 1373

Answers (2)

Vitamin C
Vitamin C

Reputation: 931

We have exactly same issue. And we do re-create whole subscription in OnError event just in case. It is also interesting that multiple application instances running on separate boxes exhibit identical behavior: at some point they just stop receiving notifications. Restarting any and all of them doesn't help; they do successfully subscribe but still no notifications other than OnDisconnect. Restarting Exchange Server is what really helps, though for a while.

Upvotes: 1

Ahmad ElMadi
Ahmad ElMadi

Reputation: 2617

I can see that the problem here is that you are trying to open the connection in the OnError handler. The problem here is that when OnError happen, the connection normally loses all the subscriptions, so you might need to consider creating the subscriptions again before opening them.

Upvotes: 0

Related Questions