当前位置: 代码迷 >> Web Service >> WCF 基础联接已经关闭:连接被意外关闭(大数据量)
  详细解决方案

WCF 基础联接已经关闭:连接被意外关闭(大数据量)

热度:273   发布时间:2016-05-02 02:45:45.0
WCF 基础连接已经关闭:连接被意外关闭(大数据量)
表的字段有64个,查询1000条以内的没有问题,1000以上就报错。配置里需要改的也改了。使用trace_log跟踪提示的是
“进行序列化时出错: ReadVAJ1sResult。InnerException 消息是“对象图中可以序列化或反序列化的项目数目上限为“65535”。请更改对象图或增加 MaxItemsInObjectGraph 的配额”,但是,该配置我已经改过了,还提示这个异常。
另外,我在把服务端的MaxItemsInObjectGraph改成1的时候,程序依然是在1000条以内正常,1000以上报错。我感觉是不是我的服务端的配置没起作用?或者还有其它什么原因引起的这个错误。

附:客户端和服务端配置

服务端:

<system.serviceModel>
      <services>
      <service behaviorConfiguration="ServiceBehavior" name="Service.Service">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="testBinding"
          contract="IContract.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <timeouts closeTimeout="10:10:10" />
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
           <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

      <bindings>
          <basicHttpBinding>
              <binding name="testBinding" closeTimeout="10:50:00" openTimeout="10:10:00"
                  receiveTimeout="10:10:00" sendTimeout="10:10:00" allowCookies="false"
                  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="2147483647" maxBufferPoolSize="2146483647"
                  maxReceivedMessageSize="2147483647" messageEncoding="Text"
                  textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  相关解决方案