为什么 Binding.CloseTimeout 值被忽略?

发布于 2024-11-11 15:18:36 字数 444 浏览 4 评论 0原文

会话客户端将 Binding.CloseTimeout 设置为 20 秒:

<netTcpBinding>
  <binding name="NetTcpBinding_IService" closeTimeout="00:00:20" ...

a) 如果客户端调用 proxy.Close 时服务未运行,则客户端应等待 20 秒(由于 CloseTimeout 在抛出异常之前被设置为 20 秒),但异常几乎立即抛出:

»套接字连接被中止。这可能是由于处理消息时出错、远程主机超出接收超时或底层网络资源问题造成的。本地套接字超时为“00:00:20”。«

为什么客户端会忽略 CloseTimeout 值?

谢谢

Sessionful client has Binding.CloseTimeout set to 20 seconds:

<netTcpBinding>
  <binding name="NetTcpBinding_IService" closeTimeout="00:00:20" ...

a) If service isn't running at the time client calls proxy.Close, then client should wait for 20 seconds ( due to CloseTimeout being set to 20 seconds ) before throwing an exception, but instead exception is thrown almost immediately:

»The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:20'.«

Why is CloseTimeout value ignored by client?

thank you

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

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

发布评论

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

评论(1

倚栏听风 2024-11-18 15:18:36

想象一下客户端和服务器是人,他们中午开会。

中午客户准时出现。如果服务器不在那里,那么客户端会立即离开,并说“管它的!” (抛出异常)。

如果服务器在那里,它们就会开始协商(建立连接)。如果会议持续时间少于 CloseTimeout,这是因为他们已达成协议(连接已建立)。如果会议时间耗尽,他们就会放弃谈判(连接尝试超时)。

以免您认为我在编造这一点,MSDN 上的这个问题

EncpointNotFoundException [原文如此] 如果在指定地址上找不到服务,通常会发生。该异常将立即抛出。但如果找到服务,但在 20 秒内无法建立会话通道,则会遇到超时错误。

Imagine the client and server are people, and they have a meeting at noon.

The client shows up promptly at noon. If the server isn't there then the client leaves immediately, saying "Screw it!" (throwing an exception).

If the server is there, they commence negotiations (setting up a connection). If the meeting lasts less than CloseTimeout it's because they've come to an agreement (the connection has been set up). If they run out of time for the meeting, they abandon their negotiations (the connection attempt times out).

Lest you think I'm making this up, it's confirmed by the answer to this question over on MSDN:

EncpointNotFoundException [sic] usually occurs if the service cannot be found on the specified address. This exception will be thrown immediately. But if the service is found, yet the sessionful channel cannot be established within 20 seconds, you'll encounter the timeout error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文