質問

Microsoft Exchange Web Services 1.1 SDKを使用しており、ストリーミング接続を使用して新しいメール通知を購読しています。すべては通知を受信するために正常に動作しますが、私の交換がサブスクリプションを見つけることができないことについて、たまにエラーを受け取ります。

以下は、サブスクリプションを初期化するために使用しているコードと使用するイベントです。

public void Subscribe()
{
    var locateMailbox = new Mailbox
                            {
                                Address = "myemail"
                            };
    var folderId = new FolderId(WellKnownFolderName.Inbox, locateMailbox);
    var foldersToWatch = new[] {folderId};
    StreamingSubscription streamingSubscription =
        _exchangeService.SubscribeToStreamingNotifications(foldersToWatch, EventType.NewMail);
    // Timeout is set at 1 minute intentionally
    var streamingConnection = new StreamingSubscriptionConnection(_exchangeService, 1);

    streamingConnection.AddSubscription(streamingSubscription);

    streamingConnection.OnSubscriptionError += ResolveError;
    streamingConnection.OnDisconnect += Reconnect;

    streamingConnection.Open();
}

public void Reconnect(object sender, SubscriptionErrorEventArgs disconnectEventArgs)
{
    if (!((StreamingSubscriptionConnection)sender).IsOpen)
        ((StreamingSubscriptionConnection)sender).Open();
}

public void ResolveError(object sender, SubscriptionErrorEventArgs errorEventArgs)
{
    var streamingSubscriptionConnection =
        (StreamingSubscriptionConnection) sender;
    if (!streamingSubscriptionConnection.IsOpen)
        streamingSubscriptionConnection.Open();
}

ServiceLocalException - You must add at least one subscription to this connection before it can be opened.

その例外はそれ自体を物語っています、そして、私は単に内部に別のサブスクリプションを作成できることを知っています Reconnect(). 。誰かがサブスクリプションがどこに向かっているのかを理解するのを手伝ってくれることを願っています。 Exchange 2010などの製品が単にサブスクリプションを失うことは想像できません。また、エラーを特定することはできません。サブスクリプションを10分間アクティブに保つことができ、他の場合には、2〜3分後にサブスクリプションが有効でないというエラーを受け取ることもあります。

私がExchange2010 SP1を使用している価値のために。

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top