EWS 托管 API:通常只允许每个套接字地址(协议/网络地址/端口)使用一次
我们正在开发软件,允许我们的自定义计划应用程序(主角色)与 Microsoft Exchange Server 2010/2007(从角色)同步。我们的解决方案基于 .NET 4.0、EWS Managed API 和 Parallel Fx,当然还有我们自己的 C# 代码。我们特别注意了这样一个事实:“ExchangeService”类实例不会被多个线程同时使用,并且在实例总数方面是保守的(我们目前在任何给定时间都有 10 个活动实例)。然而,我们确实进行了大量调用(FindItems、CreateItems、UpdateItems、DeleteItems、LoadPropertiesForItems)。
深入挖掘后,我们发现这种方法并没有给我们带来太多好处。每当发出操作时,都会创建、执行并关闭新的 HttpWebRequest。对于经过身份验证的请求(在我们的示例中:https + WebCredentials),底层 tcp 连接似乎以 TIME_WAIT 状态返回到操作系统(如本文所述:msdn.microsoft.com/en-us/library/aa560610( BTS.10).aspx) 并坐在那里,4 分钟内什么都不做(默认情况下)。我们已经应用了上面文章中的建议(可以在此处找到进一步的讨论:blogs.msdn.com/b/dgorti/archive/2005/09/18/470766.aspx),并将“坐在那里”时间减少到 30秒。这在测试环境中一切都很好,但在生产系统上却不行,在生产系统中,tcp 连接是一种更稀缺的资源,而且我们的应用程序并不是唯一使用它们的应用程序。
我认为问题与 EWS 托管 API 如何使用 HttpWebRequest (甚至在 System.Net 中更深入)有关。我们想玩弄 msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing.aspx 和 msdn.microsoft.com/en-us/library/6y3d5dts.aspx,但由于 EWS 托管 API 中的所有内容无论是内部的还是密封的,都很难扩展/尝试。
欢迎提供有关如何进行的建议!
We're developing software that allows our custom scheduling application (master role) to synchronize with Microsoft Exchange Server 2010/2007 (slave role). Our solution is based on .NET 4.0, the EWS Managed API and Parallel Fx, and of course our own C# code. We've taken special care of the fact that "ExchangeService" class instances are not used by multiple threads concurrently and are conservative regarding the total number of instances (we currently have 10 live instances at any given time). We do however make a lot of calls (FindItems, CreateItems, UpdateItems, DeleteItems, LoadPropertiesForItems).
Digging deeper, we've found that this approach doesn't buy us really much. Whenever an operation is issued a new HttpWebRequest is created, executed and closed. For authenticated requests (in our case: https + WebCredentials) it appears that the underlying tcp connection is returned to the OS with a state of TIME_WAIT (as described in this article: msdn.microsoft.com/en-us/library/aa560610(BTS.10).aspx) and sits there, doing nothing for 4 minutes (by default). We already applied the suggestions in the above article (further discussion can be found here: blogs.msdn.com/b/dgorti/archive/2005/09/18/470766.aspx), and reduced the "sits there" time to 30 seconds. This is all fine in a test environment, but not on a production system where tcp connections are a more scarce resource and our app is not the only one using them.
I think the problem has to do with how the EWS Managed API is using HttpWebRequest (or even deeper in System.Net). We wanted to toy with msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing.aspx and msdn.microsoft.com/en-us/library/6y3d5dts.aspx but since everything in the EWS Managed API is either internal or sealed, it becomes difficult to extend/try this out.
Advice on how to proceed welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论