【问题标题】:The HTTP request to *.svc has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.对 *.svc 的 HTTP 请求已超过分配的超时。分配给此操作的时间可能是较长超时的一部分。
【发布时间】:2011-05-07 05:06:03
【问题描述】:

我一直在使用 WCF 开发 Silverlight 应用程序。

问题是有时它会抛出异常说明:

“对 'http://localhost:1276/Foo.svc' 的 HTTP 请求已超过分配的超时时间。分配给此操作的时间可能是较长超时时间的一部分。”

那么如何增加时间跨度?有些人建议在 web config 和 service.client 配置文件中使用接收超时,如下所示

 <bindings>
      <customBinding >
        <binding  name="customBinding0" receiveTimeout="02:00:00" >
          <binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647" />


          <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Buffered"/>

        </binding>
      </customBinding>      
    </bindings>

receiveTimeout 属性的最大值是多少?

【问题讨论】:

    标签: silverlight wcf timeout


    【解决方案1】:

    我想问题不在于您的 ReceiveTimeout 超出了该设置的最大值,因为 TimeSpan 的 MaxValue 超过 1000 万天。相反,我认为这些设置只是没有生效。

    您应该尝试增加服务器端和客户端的超时值:

    在服务器上(在您的 web.config 中)

    <binding name="customBinding0" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00">
    

    在客户端(在您的 ServiceReferences.ClientConfig 中)

    <binding name="CustomBinding_DesignOnDemandService" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00">
    

    【讨论】:

    • 恰好发生在我身上,我更改了 web.config 中的设置,但没有反映。原因是我的应用程序从它自己的设置文件“不是来自 web.config”中设置值
    【解决方案2】:

    HTTP 请求已超过分配的超时。分配给此操作的时间可能是较长超时的一部分。

    三个地方设置时间值来解决这个问题……

    1. Web.Config

      <httpRuntime executionTimeout="600" />
      

      (这是秒,所以这里是 10 分钟)。在此处了解有关 httpRuntime 的更多信息。

    2. 在您的 Web.Config 绑定元素上

      <binding name="customBinding123"     receiveTimeout="00:10:00"     sendTimeout="00:10:00"     openTimeout="00:10:00"     closeTimeout="00:10:00" />
      
    3. 在 system.serviceModel 中的 ServerReferences.ClientConfig 绑定元素上

      <binding name="CustomBinding"     receiveTimeout="00:10:00"     sendTimeout="00:10:00"     openTimeout="00:10:00"     closeTimeout="00:10:00" />
      

    【讨论】:

    • web 配置、客户端配置以及 executionTimeout 中的所有绑定都设置为 10 分钟,但我仍然在 1 分钟时得到超时。
    【解决方案3】:

    几天前,我们收到了同样的错误消息。我找到了这个线程,但是在我们开始增加不同的超时属性之前,我们检查了客户端机器的杀毒软件:它是NOD。较新的 NOD(可能还有其他 AV)具有端口过滤器/阻塞的可能性。我们关闭了 80/443 端口阻塞,客户端连接没有任何超时错误信息。

    【讨论】:

      猜你喜欢
      • 2012-12-22
      • 2020-05-01
      • 2013-03-08
      • 2011-04-19
      • 1970-01-01
      • 2014-09-29
      • 2018-04-25
      • 1970-01-01
      • 2019-06-08
      相关资源
      最近更新 更多