WCF频道:服务器在10分钟后没有响应

问题描述 投票:1回答:2

我创建了一个由客户端和服务器组成的体系结构,这些体系结构在localhost中的WCF通道上进行通信,一切正常,但如果两个服务器之间没有活动(来自客户端的请求)超过10分钟,则服务器不响应了。连接仍然存在但是服务器没有响应客户端请求,因此客户端必须断开连接并重新连接才能向服务器发送请求。也许我让一些参数滑落。

我使用的地址是:net.tcp:// localhost:8080 / ICS;频道类型:双工;

c# wcf wcf-data-services wcf-binding wcf-security
2个回答
1
投票

这里的问题是在receiveTimeout。服务主机使用此超时来确定何时删除空闲连接。如果在配置的时间跨度内未收到任何消息,则表示连接已关闭。默认情况下是10分钟。


0
投票

更新,ReliableMessaging未启用因此编辑InactivityTimeout毫无意义

而改变我的绑定设置的ReceiveTimeout参数解决了这个问题。

我的代码:

var bind = new NetTcpBinding();                   // my binding instance
var relSessionEnabled = bind.ReliableSession.Enabled;            // this is false
var inactivityTimeout = bind.ReliableSession.InactivityTimeout;  // this is 10 minutes
bind.ReceiveTimeout = TimeSpan.MaxValue;          // this was 10 minutes before this instructuion
© www.soinside.com 2019 - 2024. All rights reserved.