读书人

一个WCF有关问题

发布时间: 2012-12-18 12:43:41 作者: rapoo

求助一个WCF问题
用WCF写了一个程序,服务端是自托管的,服务模式用的是Session,NetTcpBinding,代码如下:


public static class BindingUtility
{
public static TimeSpan CloseTimeout = TimeSpan.FromMinutes(2);
public static TimeSpan OpenTimeout = TimeSpan.FromMinutes(2);
public static TimeSpan SendTimeout = TimeSpan.FromMinutes(5);
public static TimeSpan ReceiveTimeout = TimeSpan.FromHours(1);
public static TimeSpan InactivityTimeout = TimeSpan.FromSeconds(1);

public static System.ServiceModel.NetTcpBinding CreateNetTcpBinding()
{
return new System.ServiceModel.NetTcpBinding()
{
CloseTimeout = BindingUtility.CloseTimeout,
OpenTimeout = BindingUtility.OpenTimeout,
SendTimeout = BindingUtility.SendTimeout,
ReceiveTimeout = BindingUtility.ReceiveTimeout,
TransactionFlow = false,
TransferMode = TransferMode.Buffered,
MaxBufferPoolSize = int.MaxValue,
MaxBufferSize = int.MaxValue,
MaxConnections = 30,
ListenBacklog = 30,
MaxReceivedMessageSize = int.MaxValue,
ReliableSession = new OptionalReliableSession()
{
Ordered = true,
InactivityTimeout = BindingUtility.InactivityTimeout,
Enabled = true
},
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxDepth = 128,


MaxStringContentLength = int.MaxValue,
MaxArrayLength = int.MaxValue,
MaxBytesPerRead = int.MaxValue,
MaxNameTableCharCount = int.MaxValue
},
Security = new NetTcpSecurity()
{
Mode = SecurityMode.None
}
};
}
}



客户端每秒会调用一个服务方法,这个方法的功能是将SessionID保存或更新,当其他客户端调用服务的其他方法时,用于回调客户端执行一个更改通知

遇到的问题如下:

1:单机调试的时候,只要设置了断点,中断后马上继续运行,客户端调用服务的方法都会报错:CommunicationObjectFaultedException

2:网络调试的时候,如果使用的是无线连接,除本机外的其他机器会经常不定时报错CommunicationObjectFaultedException
如果使用的是有线连接,同样会收到CommunicationObjectFaultedException但时间则被大大延长,有时几个小时都没有问题。
单机运行多个客户端则没有问题。

这个问题大家有没有什么办法解决?

[最优解释]
将InactivityTimeout改大试试或者换用PERCALL模式。
[其他解释]
客户端用的同一个代理?

读书人网 >Web Service

热点推荐