WCF ServiceHost 关闭操作超时
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
服务器端发生错误
The ServiceHost close operation timed out after 00:00:10. This could
be because a client failed to close a sessionful channel within the
required time. The time allotted to this operation may have been a
portion of a longer timeout.
客户端产生错误:
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;
}
}
我已经解决了应用程序池在托管服务器上不断重启的问题。
我有这个巨大的超时问题,我不知道如何解决它! 我正在使用 windows 服务客户端通过 HTTPS
连接到 WCF 服务我看过这个: http://blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx
服务器端发生错误
The ServiceHost close operation timed out after 00:00:10. This could be because a client failed to close a sessionful channel within the required time. The time allotted to this operation may have been a portion of a longer timeout.
客户端产生错误:
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;
}
}
我已经解决了应用程序池在托管服务器上不断重启的问题。