WCF 基础连接已经关闭: 服务器关闭了本应保持活动状态的连接。

详细错误信息:

    System.ServiceModel.CommunicationException: 接收对 http://localhost:48655/XXXXXX.svc 的 HTTP 响应时发生错误。这可能是由于服务终结点绑定未使用 HTTP 协           议造成的。这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。有关详细信息,请参见服务器日志。

    System.Net.WebException: 基础连接已经关闭: 接收时发生错误。

    System.IO.IOException: 无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。。

    System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接。

解决方法: 写日志。

http://stackoverflow.com/questions/19518978/system-servicemodel-communicationexception-the-underlying-connection-was-closed

<serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <dataContractSerializer maxItemsInObjectGraph="6553500"/>
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
<system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true">
      <listeners>
        <add name="traceListener"
            type="System.Diagnostics.XmlWriterTraceListener"
            initializeData= "c:	emplogTraces.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

       

原文地址:https://www.cnblogs.com/xiaoyu369/p/6606407.html