【问题标题】:RIA services WCF timeoutRIA 服务 WCF 超时
【发布时间】:2011-01-14 15:07:51
【问题描述】:

我有一个用 silverlight 3.0 编写的应用程序。它使用 RIA 服务在客户端和服务器之间进行通信。

我的问题在网上似乎没有得到很好的回答。客户端使用 RIA 服务与服务器通信,后者在后台使用 WCF。如果通信时间超过 60 秒,则会显示此消息超时,

'查询'ApplyUpgrade'的加载操作失败。对“http://localhost:52403/ClientBin/DatabaseUpgradeTool-Web-UpgradePackageDomainService.svc/binary”的 HTTP 请求已超过分配的超时时间。分配给此操作的时间可能是较长超时的一部分。'

我的服务器正在执行数据库升级,因此需要超过 60 秒才有效。可能是两倍或三倍。

我在 web.config 中尝试过这样的设置,

<services>
    <service name="DatabaseUpgradeTool.Web.UpgradePackageDomainService">
      <endpoint address="" binding="wsHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint>
      <endpoint address="/soap" binding="basicHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint>
      <endpoint address="/binary" binding="customBinding" bindingConfiguration="BinaryHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint>
    </service>
  </services>
<bindings>
    <customBinding>
      <binding name="BinaryHttpBinding"
               receiveTimeout="00:00:10"
               sendTimeout="00:00:10" 
               openTimeout="00:00:10" 
               closeTimeout="00:00:10">
        <binaryMessageEncoding   />
        <httpTransport keepAliveEnabled="true"/>
      </binding>
    </customBinding>
  </bindings>

仍然没有喜悦。关于我上面尝试过的有什么问题的任何想法?我希望以上内容会导致它在 10 秒内超时,而不是 60 秒。

谢谢。

【问题讨论】:

  • 请注意上面更新的问题。我尝试了web.config中的一些设置,但都没有生效。它可能会引发其他一些见解

标签: c# .net silverlight-3.0


【解决方案1】:

我遇到了同样的问题,我在这里发布了这个问题的答案:Silverlight 4 WCF RIA Service Timeout Problem

答案如下:

我会解释我的背景,我希望它对我有用。我很确定。

首先调用 RIA 服务,并使用一些域上下文,在我的示例中:

EmployeeDomainContext context = new EmployeeDomainContext();
InvokeOperation<bool> invokeOperation = context.GenerateTMEAccessByEmployee(1, 'Bob');
invokeOperation.Completed += (s, x) =>
    {....};

在此之前没有什么新鲜事。有了这个,我每次在 1 分钟后都面临同样的超时异常。我花了很多时间试图面对如何更改超时定义,我尝试了 Web.config 中所有可能的更改,但什么也没做。解决方案是:

创建一个CustomEmployeeDomainContext,这是一个局部类本地化在生成代码的同一路径,这个类使用钩子方法OnCreate来改变创建的域上下文的行为。在这堂课中,你应该写:

public partial class EmployeeDomainContext : DomainContext
{
    partial void OnCreated()
    {
        PropertyInfo channelFactoryProperty = this.DomainClient.GetType().GetProperty("ChannelFactory");
        if (channelFactoryProperty == null)
        {
            throw new InvalidOperationException(
              "There is no 'ChannelFactory' property on the DomainClient.");
        }

        ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(this.DomainClient, null);

        factory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 10, 0); 

    }
}

期待您的反馈。

【讨论】:

    【解决方案2】:

    不确定这是否有帮助,我没有尝试过超时配置,但它可能会为您指明正确的方向: http://blogs.objectsharp.com/CS/blogs/dan/archive/2010/04/13/maxitemsinobjectgraph-wcf-ria-services-exception.aspx

    【讨论】:

      猜你喜欢
      • 2013-05-12
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 2011-03-26
      相关资源
      最近更新 更多