The underlying connection was closed: The connection was closed unexpectedly

前端 未结 10 1033
忘掉有多难
忘掉有多难 2020-12-08 11:40

This exception is consistently thrown on a SOAP Request which takes almost three minutes to receive and is 2.25 megs in size.

When scouring the web I find all sorts

相关标签:
10条回答
  • 2020-12-08 12:15

    This is a generic error raised if there is an internal error.

    Try adding tracing here: http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx

    You will see the full log then.

    0 讨论(0)
  • 2020-12-08 12:17

    If you are using dbml instead of edmx you will get this( The underlying connection was closed: The connection was closed unexpectedly.) as dbml will not return serialisable data it needs datacontract so go to properties of dbml file and change the Serialization mode to unidirectional.

    0 讨论(0)
  • 2020-12-08 12:17

    Have you tried the sugestion of this Blog Post? The problem will most probably lie in the TCP/HTTP stack implementation of .NET .

    0 讨论(0)
  • 2020-12-08 12:22

    Tried several ways to get rid of this error message until I found this solution: http://kiranpatils.wordpress.com/2008/09/22/the-underlying-connection-was-closed-the-connection-was-closed-unexpectedly-while-returning-data-table-from-wcf-service/

    You may change your List<> to DataSet. I suspect DataSet can handle much amount of data than the List<>.

    Hope it helps.

    0 讨论(0)
  • 2020-12-08 12:23

    You tagged the post as .NET35, so are you using WCF?

    If so, here is an example of the App.config we use for large data sets:

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="32" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:1602/EndPoint.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="IEndPointContract" name="EndPoint" behaviorConfiguration="EndpointBehaviour" />     
        </client>
        <behaviors>
          <endpointBehaviors>
            <behavior name="EndpointBehaviour">
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
          </endpointBehaviors>
        </behaviors>
      </system.serviceModel>
    
    0 讨论(0)
  • 2020-12-08 12:23

    I have added another field, but didn't have a set on the property. That was my solution for the same error.

    [DataMember]
    public bool HasValue
    {
        get { return true; }
        set { }//adding this line made the solution.
    }
    
    0 讨论(0)
提交回复
热议问题