[英]WCF ServiceHost close operation timedout
我有一個巨大的超時問題,我不知道如何解決它! 我正在使用Windows服務客戶端通過HTTPS連接到WCF服務
我已經看過了: http : //blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx
服務器端生成錯誤
ServiceHost關閉操作在00:00:10之后超時。 這可能是因為客戶端未能在所需時間內關閉會話通道。 分配給該操作的時間可能是較長超時的一部分。
客戶端生成的錯誤:
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose()
這是我對WCF服務的約束:
<bindings>
<wsHttpBinding>
<binding name="Binding1" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" />
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
這是代碼客戶端:
wsHttpBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential)
{
CloseTimeout = new TimeSpan(0, 0, 10, 0),
OpenTimeout = new TimeSpan(0, 0, 10, 0),
ReceiveTimeout = new TimeSpan(0, 10, 0, 0),
SendTimeout = new TimeSpan(0, 0, 10, 0),
TransactionFlow = false,
MaxBufferPoolSize = 524288,
MaxReceivedMessageSize = 2147483647,
ReaderQuotas =
{
MaxDepth = 128,
MaxStringContentLength = int.MaxValue,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 16384,
MaxNameTableCharCount = 16384
}
};
wsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
wsHttpBinding.ReliableSession.Ordered = true;
wsHttpBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 0, 10, 0);
wsHttpBinding.ReliableSession.Enabled = true;
Ednpoint = new EndpointAddress(new Uri(URL));
myChannelFactory = new ChannelFactory<IPoint>(wsHttpBinding, Ednpoint);
myChannelFactory.Endpoint.Contract.SessionMode = SessionMode.Allowed;
ClientCredentials cc = myChannelFactory.Endpoint.Behaviors.Find<ClientCredentials>();
cc.UserName.UserName = usr;
cc.UserName.Password = pass;
myChannelFactory.CreateChannel();
我正在使用此代碼發送像這樣的數據:
using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel())
{
client.OperationTimeout = TimeSpan.FromMinutes(10);
IPoint wcfClient1 = (IPoint)client;
for (int start = startpos; start < totalSize; start += size)
{
List<Point> send = r.Skip(start).Take(size).ToList();
xreturn = wcfClient1.Update(send);
counter += 1;
}
}
我已經解決了應用程序池不斷在托管服務器上重新啟動的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.