WCF - 仅限生产服务器 - 接收 HTTP 响应时出错

WCF - Production server only - An error occurred while receiving the HTTP response

我在我们的生产服务器上遇到了一个奇怪的问题

接收对 http://end-http://xxxxx/Main.svc 的 HTTP 响应时发生错误。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于 HTTP 请求上下文被服务器中止(可能是由于服务关闭)。有关详细信息,请参阅服务器日志。

网站和 WCF 服务部署在同一台服务器上,它在我们的 QA 环境中运行良好,但相同的代码和绑定设置在生产服务器上不起作用。

我们在 WCF 服务上有以下绑定设置

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

WCF 客户端

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMain"  maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                 maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://abc/DataService/Main.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IMain" contract="DALService.IMain"
        name="BasicHttpBinding_IMain" />
    </client>
  </system.serviceModel>

有人可以帮我解决这个问题吗?

非常感谢 米奇

最后,我设法修复了它,修复方法是在 WCF 服务器配置中添加以下设置。

 <serviceBehaviors>
        <behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
</behavior>
      </serviceBehaviors>