WCF超时问题

时间:2011-11-14 08:23:25

标签: silverlight wcf timeout

我是WCF技术的新手,我从我的silverlight应用程序调用此WCF。

现在,我在WCF中定义了一个函数,该函数调用安装在同一台PC上的数据库上的SP。

此SP需要1分钟的时间来执行,并返回包含50列的82000行。

我已在我的应用程序中将wcf超时间隔设置为20分钟。

现在,当我从我的silverlight应用程序调用此WCF函数时,它会在20分钟后给出超时错误。由于SP需要1分钟才能执行,我想知道为什么会出现超时问题?

导致超时的原因是什么?我该怎么做才能避免这种情况?我无法一次性实现分页或任何我需要的所有数据。

请帮帮我们。我附上了我的web.config文件供您参考。

Silverlight web.config文件     

    <behaviors>
        <endpointBehaviors>
            <behavior name="ExportServiceRestBehavior">
                <webHttp />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="ExportServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="ExportServiceBehavior" name="DebtorBal.Web.ExportService1">
            <endpoint binding="basicHttpBinding" bindingConfiguration="ExportServiceBinding"
                contract="DevExpress.Xpf.Printing.Service.IExportService" />
            <endpoint address="rest" behaviorConfiguration="ExportServiceRestBehavior"
                binding="webHttpBinding" bindingConfiguration="ExportServiceRestBinding"
                contract="DevExpress.Xpf.Printing.Service.IExportServiceRest" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <bindings>
        <basicHttpBinding>
            <binding name="ExportServiceBinding" maxReceivedMessageSize="50000000"
                transferMode="Streamed">
                <security>
                    <transport realm="" />
                </security>
            </binding>
            <binding name="myBindingForBigArrays" closeTimeout="00:10:00"
                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="64" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security>
                    <transport realm="" />
                </security>
            </binding>
        </basicHttpBinding>
        <webHttpBinding>
            <binding name="ExportServiceRestBinding" transferMode="Streamed" />
        </webHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:49261/LsnMonService.svc"
            binding="basicHttpBinding" bindingConfiguration="myBindingForBigArrays"
            contract="ServiceReference1.ILsnMonService" name="BasicHttpBinding_ILsnMonService" />
    </client>
</system.serviceModel>

WCF配置文件

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
        <serviceThrottling maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

1 个答案:

答案 0 :(得分:1)

这可能比那简单。您是否关闭或处置您的服务?如果没有,则很可能您的服务连接仍处于打开状态。一旦达到超时限制就会出错。从中获取数据后,明确关闭服务。