Search code examples
wcfiis

WCF Rest ERR_CONNECTION_RESET not large response


The error code is absolutely terrible, ERR_CONNECTION_RESET has a host of causes and the causes that I found on other questions were related to having too small of a MaxRequestLength for large web service calls. The data I was returning was only a couple of kB though, so this couldn't be the issue.

Here is my interface code

[WebGet(RequestFormat = WebMessageFormat.Json,
  BodyStyle = WebMessageBodyStyle.WrappedRequest,
  ResponseFormat = WebMessageFormat.Json,
  UriTemplate = "GetReportByID?ReportID={ReportID}")]
[OperationContract]
UsageReport GetReportByID(int ReportID);

This was the implementation

public UsageReport GetReportByID(int ReportID)
{
    return new UsageReport(ReportID);
}

And this was the class code for UsageReport

[DataContract]
public class UsageReport
{
 [DataMember]
List<UsageItem> RL;

  public UsageReport(int reportID)
{
       RL = new List<UsageItem>();

        using (SqlDataReader dr = DBUtility.ExecuteReader(cmd, "DBString"))
        {
            while (dr.Read())
            {

                ItemNumber = dr["ItemID"] as int? ?? 0;
                RL.Add(new UsageItem(ItemNumber));
            }
            dr.Close();
        }
}



public class UsageItem
{
    int ItemNumber;

    public UsageItem(int ItemNumber)
    {
        this.ItemNumber = ItemNumber;

    }

}

Solution

  • The problem was my UsageItem class, I was missing the necessary DataContract and DataMember fields.

    [DataContract]
    public class UsageItem
    {
    [DataMember]
    int ItemNumber;
    
    public UsageItem(int ItemNumber)
      {
        this.ItemNumber = ItemNumber;
    
    
      }
    
    }