locked
The underlying connection was closed: An unexpected error occurred on a receive RRS feed

  • Question

  •  

    Hi All,

     

    i have developed a web application to call WCF service (which is hosted in IIS) from client application using .Net 1.1

    it works fine.

     

    but i got an error "The underlying connection was closed: An unexpected error occurred on a receive." when the return object is getting complex.

     

    i analysis the issue with different level of object complexity and i found it get failed for following structure.

     

    eg:

     

    ObjectA - outer object that has some primitive data types and the list of ObjectB

    ObjectB - this also contain some primitive data and list of ObjectC.

     

    Hope you can understand the hierarchy (complexity) of the return object.

    This works up to 2nd level of object hierarchy.

     

    Does anyone have idea about the solution for this exception?

     

    Thanks in Advance

    Shazvi

    Thursday, October 4, 2007 10:18 AM

All replies

  • Please post the entire exception, including any InnerException. One way to do this is to display Exception.ToString.

     

    There may be useful information that you're ignoring by not looking at the entire exception. In particular, it's difficult to see how object complexity could cause a networking error. This suggests that this is not a networking error, despite the exception message you posted. I suspect that the remainder of the exception will show us what sort of non-networking error this is.

     

    You may also want to look at the following thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2229819&SiteID=1. This is from a poster who was also trying to get .NET 1.1 to interoperate. His problem was that his service was using platform-specific data, specifically nullable types. .NET 1.1 didn't like that.

    Thursday, October 4, 2007 9:30 PM
    Moderator
  • Hi,

     

    Thanks for your quick respond.

    Yes, you are correct. It’s cannot be a network error. Because this same method working with high volume of data. I’m suspect this issue might cause on serialization/ de-serialization.

    In my case inner exception also gives same error message. It doesn’t give in detail about the exception.

    I’m sure server side doesn’t give any error it works fine.

     

    Below given is the entire error message displayed on page.

     

     

    The underlying connection was closed: An unexpected error occurred on a receive.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

     

    Exception Details: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.

     

    Source Error:

      

    Line 79:         [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/IMyService/MyOperation1", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

    Line 80:         public RetentionScheduleDTO MyOperation1(Context context, OrgRetentionScheduleIdentity orgRetentionScheduleIdentity, RetentionScheduleInformationLevel infoLevel) {

    Line 81:             object[] results = this.Invoke("MyOperation1", new object[] {

    Line 82:                         context,

    Line 83:                         orgRetentionScheduleIdentity,

      

    Source File: c:\inetpub\wwwroot\webapplication2\web references\imtestwcf\reference.cs    Line: 81

     

    Stack Trace:

      

    [WebException: The underlying connection was closed: An unexpected error occurred on a receive.]

       System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

       System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

       System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

       WebApplication2.IMTestWCF.MyService.MyOperation1(Context context, OrgRetentionScheduleIdentity orgRetentionScheduleIdentity, RetentionScheduleInformationLevel infoLevel) in c:\inetpub\wwwroot\webapplication2\web references\imtestwcf\reference.cs:81

       WebApplication2.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication2\webform1.aspx.cs:148

       System.Web.UI.WebControls.Button.OnClick(EventArgs e)

       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

       System.Web.UI.Page.ProcessRequestMain()

       

    --------------------------------------------------------------------------------

    Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407

     

      

    Thanks & Regards,

    Shazvi

    Friday, October 5, 2007 7:14 AM
  • My next suggestion is that you surround the call to your web method with a try/catch block. Specifically, catch (System.Net.WebException ex). WebException has additional properties that may provide insight into the problem.

     

    Friday, October 5, 2007 5:29 PM
    Moderator
  • hi, i am also facing similar problem. here is the System.Net.WebException but havent got any extra information.

    ========================

    {"The underlying connection was closed: The connection was closed unexpectedly."}

    [System.Net.WebException]: {"The underlying connection was closed: The connection was closed unexpectedly."}

    Data: {System.Collections.ListDictionaryInternal}

    HelpLink: null

    InnerException: null

    Message: "The underlying connection was closed: The connection was closed unexpectedly."

    Source: "System.Web.Services"

    StackTrace: " at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)\r\n at Microsoft.Web.Services3.WebServicesClientProtocol.GetResponse(WebRequest request, IAsyncResult result)\r\n at Microsoft.Web.Services3.WebServicesClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n at Avalara.AvaTax.Services.Proxies.AccountSvcProxy.AccountSvcWse.CompanyFetch(CompanyFetchRequest FetchRequest) in C:\\[folder path]\Reference.cs:line 2652\r\n at Test.Avalara.AvaTax.Services.Account.SecurityTests.TechSupportUserWithUserTokenTest() in C:\\[folder path]\\SecurityTests.cs:line 678"

    TargetSite: {System.Net.WebResponse GetWebResponse(System.Net.WebRequest)}

    Tuesday, June 23, 2009 6:48 AM
  • You should not assume this has anything to do with the original thread. Please start a new thread, and please provide some detail. For instance, what .NET versions are being used on the client and the service? How often does this happen? Are there firewalls running on either the client or service, etc.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of old ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, June 23, 2009 10:03 AM
    Moderator
  • Looks like v4005 has the same problem as the OP to me. I, too, have the same issue. Nothing special, I'm returning a complex object, I share the service interface on client and server, and I get this same error. I'm using .NET 3.5, basicHttpBinding, localhost w/ everything (hostname of service is named w/ hosts file), hosted on IIS 7, no firewalls, and nothing special that I can see is worth quoting.
    Monday, December 21, 2009 6:21 AM
  • One difference would be that you are using WCF, but he's using ASMX.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Friday, January 1, 2010 4:17 AM
    Moderator