EXO:使用 EWS 进行流媒体订阅在第三个连接时卡住

发布于 2025-01-13 00:02:09 字数 1143 浏览 1 评论 0原文

我目前正在修改一个解决方案,该解决方案使用对通过 PowerShell 实现的三个房间日历的流式订阅来与 Exchange Online 配合使用。我用 C# 重新实现了它,因为它似乎在 PowerShell 中不起作用(没有通知,也没有错误)。

我正在使用具有模拟权限的应用程序注册来访问日历并通过一个 ExchangeService 连接创建 FreeBusy-Changed 流通知。

对于订阅,我使用三个不同的订阅连接(由于存在三个不同的邮箱)。这是设置每个连接的代码:

var folderIds = new List<FolderId>() { new FolderId(WellKnownFolderName.Calendar, mailbox) };
var subscriptionConnection = new StreamingSubscriptionConnection(exService, 10);
subscriptionConnection.OnNotificationEvent += SubscriptionConnection_OnNotificationEvent;
subscriptionConnection.OnSubscriptionError += SubscriptionConnection_OnSubscriptionError;
subscriptionConnection.OnDisconnect += SubscriptionConnection_OnDisconnect;
var subscription = exService.SubscribeToStreamingNotifications(folderIds, EventType.FreeBusyChanged);
subscriptionConnection.AddSubscription(subscription);
subscriptionConnection.Open();
_subscriptions.Add(subscriptionConnection);

这适用于前两个订阅,但第三个订阅只是挂在方法 SubscribeToStreamingNotifications 上,直到达到超时(10 分钟)。

这不是邮箱本身的问题,因为如果我改变打开连接的顺序,它仍然是第三个。

我知道并发连接数限制为 20 个,但实际上只有 3 个,那么这里有什么问题呢?有什么想法吗?

I'm currently modifying a solution that uses streaming subscriptions to three room calendars implemented via PowerShell to work with Exchange Online. I reimplemented it in C# as it didn't seem to work in PowerShell (no notifications and no error at all).

I am using an app registration with impersonation permissions to access the calendars and create a FreeBusy-Changed streaming notification with one ExchangeService connection.

For the subscriptions I am using three different subscription connections (due to the fact that there are three different mailboxes). This is the code to setup each connection:

var folderIds = new List<FolderId>() { new FolderId(WellKnownFolderName.Calendar, mailbox) };
var subscriptionConnection = new StreamingSubscriptionConnection(exService, 10);
subscriptionConnection.OnNotificationEvent += SubscriptionConnection_OnNotificationEvent;
subscriptionConnection.OnSubscriptionError += SubscriptionConnection_OnSubscriptionError;
subscriptionConnection.OnDisconnect += SubscriptionConnection_OnDisconnect;
var subscription = exService.SubscribeToStreamingNotifications(folderIds, EventType.FreeBusyChanged);
subscriptionConnection.AddSubscription(subscription);
subscriptionConnection.Open();
_subscriptions.Add(subscriptionConnection);

This works for the first two subscriptions, but the third one just hangs there on method SubscribeToStreamingNotifications until the timeout (10mins) is reached.

It's not a problem of the mailbox itself, because if I changed the order I open the connections, it's still the third one.

I know that there is a limit of I think 20 concurrent connections, but these are only three, so what's the problem here? Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏半生如梦愿梦如真 2025-01-20 00:02:09

问题是,在 .net 中,默认情况下其并发连接数限制为 2 个,请参阅 https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.defaultconnectionlimit

因此,您需要将 defaultconnectionlimit 的值设置为27 个并发连接(这是 Office365 中的 EWS 默认并发限制)。例如

// Set the maximum number of connections per server to 27.  
ServicePointManager.DefaultConnectionLimit = 27; 

The problem is that in .net by default its limited to 2 concurrent connections see https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.defaultconnectionlimit

So you need to set the defaultconnectionlimit to value up to 27 concurrent connections (which is the EWS default concurrency limit in Office365). eg

// Set the maximum number of connections per server to 27.  
ServicePointManager.DefaultConnectionLimit = 27; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文