2

我已经用 mysql DB 创建了 wcf datatservices。我正在快速从表中获取数据。但是当我试图从视图中获取数据时,它会抛出超时异常。当直接在数据库中尝试时,数据变得非常快。

我尝试在 web.config 中设置以下内容。

 <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetHttpBinding" maxBufferPoolSize="2147483647"  closeTimeout="00:01:00"
                 openTimeout="00:01:00"  maxConnections="10"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:10:00"
          maxBufferSize="524288" maxReceivedMessageSize="2147483647" />
      </netTcpBinding>
    </bindings>
    <services>
      <service name="MyService">
        <endpoint address="http://localhost:59825" binding="netTcpBinding"
          bindingConfiguration="NetHttpBinding" name="HttpBinding" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>

仍然超时异常。

编辑1:

当我尝试使用表格时,数据正在获取。我创建了一个视图作为从同一个表中选择 *。现在它也抛出超时异常。

请帮忙。

谢谢,萨丽莎。

4

4 回答 4

2
<system.serviceModel>
  <bindings>
    <netTcpBinding>
    <binding name="longTimeoutBinding"
        receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <security mode="None"/>
    </binding>
    </netTcpBinding>
   </bindings>

  <services>
    <service name ="longTimeoutService"
      behaviorConfiguration="longTimeoutBehavior">
      <endpoint address="net.tcp://localhost/longtimeout/"
        binding="netTcpBinding" bindingConfiguration="longTimeoutBinding">

      </endpoint>
    </service>
....

编辑:

如果你没有得到那么请访问这个链接:不同超时类型的解释

于 2013-08-01T09:13:53.510 回答
1

您可能正在作为客户端的 asp.net 中设置配置。您还需要配置服务器(WCF)。

您必须在 WCF 配置中更改receiveTimeout 。

您还可以使用WCF 消息日志进行诊断。

于 2013-07-31T07:46:50.213 回答
0

我想这与 WCF 配置无关。您能否检查数据库中视图的权限,并确保他具有与表相同的权限。

于 2013-08-06T12:22:38.020 回答
0

由于该服务似乎使用较小的数据集,可能是因为您使用的是视图,因此在数据库服务器上处理结果时它处于空闲状态。在这种情况下,您需要设置inactivityTimeout

<netTcpBinding>
    <binding name="NetHttpBinding" 
             maxBufferPoolSize="2147483647"  
             closeTimeout="00:01:00"
             openTimeout="00:01:00"  
             maxConnections="10"
             receiveTimeout="00:10:00"
             sendTimeout="00:10:00"
             maxBufferSize="524288" 
             maxReceivedMessageSize="2147483647">
        <reliableSession ordered="true" 
                         inactivityTimeout="00:10:00"
                         enabled="true" />
    </binding>
</netTcpBinding>
于 2013-08-08T19:27:13.673 回答