Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat causes the OnSubscriptionError to be fired in StreamingSubscriptionConnection in EWS API?
    primarykey
    data
    text
    <p>I am getting this error in production. Don't know what exactly causes this.</p> <pre><code>OnSubscriptionError : Microsoft.Exchange.WebServices.Data.ServiceResponseException: The specified subscription was not found. </code></pre> <p>Now i want to simulate the behavior in my <strong>dev environment</strong>. </p> <ul> <li><p>I have subscribed to event <code>Connection.OnSubscriptionError</code> and my event handler is <code>OnSubscriptionError</code>. Now I want to test the handler. For that purpose I want some way to trigger that event with which i ham having trouble with.</p></li> <li><p>I have tried shutting down the exchange host service while the application is running , but that doesn't fire the <code>OnsubscriptionError Event</code>. </p></li> <li><p>I wanted to know whether the following code works when <code>OnsubscriptionError event</code> is fired. Or do i have to recreate the Subscription object before creating the connection. </p></li> </ul> <p><strong>Here is the sample code:</strong></p> <pre><code>Subscription =_exchangeService.SubscribeToStreamingNotifications( new FolderId[] { WellKnownFolderName.Inbox }, EventType.NewMail); CreateStreamingSubscription(_exchangeService, Subscription); private void CreateStreamingSubscription(ExchangeService service, StreamingSubscription subscription) { // public StreamingSubscriptionConnection(ExchangeService service, int lifetime) lifetime is in minutes and 30 mins is the maximum time till which // the connection can be open. Connection = new StreamingSubscriptionConnection(service, 30); Connection.AddSubscription(subscription); Connection.OnNotificationEvent += OnNotificationEvent; Connection.OnSubscriptionError += OnSubscriptionError; Connection.OnDisconnect += OnDisconnect; Connection.Open(); } private void OnSubscriptionError(object sender, SubscriptionErrorEventArgs args) { if (args.Exception is ServiceResponseException) { var exception = args.Exception as ServiceResponseException; } else if (args.Exception !=null) { Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL, "OnSubscriptionError() : " + args.Exception.Message + " Stack Trace : " + args.Exception.StackTrace + " Inner Exception : " + args.Exception.InnerException); } try { Connection = (StreamingSubscriptionConnection)sender; if(!Connection.IsOpen) Connection.Open(); } catch (ServiceResponseException exception) { } catch (Exception ex) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload