为什么 Binding.CloseTimeout 值被忽略?
会话客户端将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想象一下客户端和服务器是人,他们中午开会。
中午客户准时出现。如果服务器不在那里,那么客户端会立即离开,并说“管它的!” (抛出异常)。
如果服务器在那里,它们就会开始协商(建立连接)。如果会议持续时间少于
CloseTimeout
,这是因为他们已达成协议(连接已建立)。如果会议时间耗尽,他们就会放弃谈判(连接尝试超时)。以免您认为我在编造这一点,MSDN 上的这个问题:
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: