WCF ReliableSession 和超时

发布于 2024-08-19 19:35:04 字数 1379 浏览 10 评论 0原文

我有一个 WCF 服务,主要用于管理存储库中的文档。
我使用了 MS 的分块通道示例,以便我可以上传/下载大文件。
现在我与服务实现了可靠的会话,并且我看到了一些奇怪的行为。
这是我正在使用的超时值。

this.SendTimeout = new TimeSpan(0,10,0);
this.OpenTimeout = new TimeSpan(0, 1, 0);
this.CloseTimeout = new TimeSpan(0, 1, 0);
this.ReceiveTimeout = new TimeSpan(0,10, 0);
reliableBe.InactivityTimeout = new TimeSpan(0,2,0);

我有以下问题:
1.如果服务未启动&运行时,客户端在 OpenTimeout 之后不会断开连接。

我用我的测试客户端尝试了它。

场景 1:没有可靠会话: 我得到以下异常: 无法连接到 net.tcp://localhost:8788/MediaManagementService/ep1。连接尝试持续的时间跨度为 00:00:00.9848790。 TCP 错误代码 10061:无法建立连接,因为目标计算机主动拒绝它 127.0.0.1:8788

这是正确的行为,因为我已将 OpenTimeout 指定为 1 秒。

场景 2:使用 ReliableSession:
我得到同样的异常:

无法连接到 net.tcp://localhost:8788/MediaManagementService/ep1。连接尝试持续的时间跨度为 00:00:00.9692460。 TCP错误代码10061:无法建立连接,因为目标机器主动拒绝它127.0.0.1:8788。

但这条消息是在大约 10 分钟后发出的。 (我相信在SendTimeout之后) 所以在这里我刚刚启用了可靠会话,现在看起来客户端的 OpenTimeout = SendTimeout。
这是期望的行为吗?

2:使用 ReliableSession 上传大文件时出现问题:
一般规则是您必须为 maxReceivedMessageSize、SendTimeout 和 ReceiveTimeout 设置一个很大的值。
但在分块通道的情况下,最大接收消息大小并不重要,因为数据是以块的形式发送的。
所以我为 Send 和 ReceiveTimeout 设置了一个很大的值:比如 10 小时。 现在上传一切正常,但它有一个副作用,即使 Service 没有启动,由于 (1) 中提到的行为,客户端连接也需要 10 个小时才会超时。

请让我知道您对这种行为的想法。

I have a WCF service used mainly for managing documents in a repository.
I used the chunking channel sample from MS so that I could upload/download huge files.
Now I implemented reliable session with the service and I am seeing some strange behaviors.
Here are the timeout values I am using.

this.SendTimeout = new TimeSpan(0,10,0);
this.OpenTimeout = new TimeSpan(0, 1, 0);
this.CloseTimeout = new TimeSpan(0, 1, 0);
this.ReceiveTimeout = new TimeSpan(0,10, 0);
reliableBe.InactivityTimeout = new TimeSpan(0,2,0);

I have the following issues:
1. If the Service is not up & running, the clients are not get disconnected after OpenTimeout.

I tried it with my test client.

Scenario 1: Without Reliable Session:
I get the following exception:
Could not connect to net.tcp://localhost:8788/MediaManagementService/ep1. The connection attempt lasted for a time span of 00:00:00.9848790. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8788

This is the correct behavior as I have given the OpenTimeout as 1 sec.

Scenario 2: With ReliableSession:
I get the same exception:

Could not connect to net.tcp://localhost:8788/MediaManagementService/ep1. The connection attempt lasted for a time span of 00:00:00.9692460. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8788.

But this message comes after around 10 mintes . (I believe after SendTimeout)
So here I just have enabled the reliable session and now it looks like the OpenTimeout = SendTimeout for the client.
Is this desired behavior?

2: Issue while uploading huge files with ReliableSession:
The general rule is that you have to set a huge value for the maxReceivedMessageSize, SendTimeout and ReceiveTimeout.
But in the case of Chunking channel, the max received message size doesn't matter as the data is sent in chunks.
So I set a huge value for Send and ReceiveTimeout : say 10 hours.
Now the upload is going fine, but it has a side effect that, even if the Service is not up, it takes 10 hours to timeout the client connection due to the behavior mentioned in (1).

Please let me know your thoughts on this behavior.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文