C# 长期运行的WCF RIA服务调用出现错误404
我们有一个RIA服务调用,它只传递几个参数,但是它可能需要较长的时间来处理(例如20多分钟),当它到达10到15分钟左右时,我们会得到一个错误404 Not Found exception。以下是我们迄今为止为解决超时问题所做的工作: 网络配置-服务器端C# 长期运行的WCF RIA服务调用出现错误404,c#,wcf,silverlight,http-status-code-404,wcf-ria-services,C#,Wcf,Silverlight,Http Status Code 404,Wcf Ria Services,我们有一个RIA服务调用,它只传递几个参数,但是它可能需要较长的时间来处理(例如20多分钟),当它到达10到15分钟左右时,我们会得到一个错误404 Not Found exception。以下是我们迄今为止为解决超时问题所做的工作: 网络配置-服务器端 <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="t
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="" closeTimeout="01:00:00" openTimeout="01:00:00"
receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
两者似乎都没有影响到这个问题。欢迎任何意见 您是否更改了IIS中的超时?是的,没有运气。我们最终找到了一个投票解决方案。
public static class DomainContextExtensions
{
public static void ChangeWcfTimeouts(this DomainContext context)
{
PropertyInfo channelFactoryProperty =
context.DomainClient.GetType().GetProperty("ChannelFactory");
if (channelFactoryProperty == null)
{
throw new InvalidOperationException(
"There is no 'ChannelFactory' property on the DomainClient.");
}
TimeSpan timeout = new TimeSpan(1, 0, 0); // 1 Hour
ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(context.DomainClient, null);
factory.Endpoint.Binding.SendTimeout = timeout;
factory.Endpoint.Binding.CloseTimeout = timeout;
factory.Endpoint.Binding.OpenTimeout = timeout;
factory.Endpoint.Binding.ReceiveTimeout = timeout;
}
}