首页 > 解决方案 > ECONNRESET for response.write 不时返回邮递员

问题描述

我正在使用 asp.net 2.0 ashx 页面,该页面在服务器端和客户端邮递员方法中有此代码:

try {
    if (Request.RequestType == "GET")
    {
            //..        
    }else if (Request.RequestType == "POST"){       
        if (restMethod == "PostSomeAction"){    
            //some code ...
            if (pifFirma == null){
                MyCustomResponse myCustomResponse = new MyCustomResponse();
                myCustomResponse.Code = "NoFirmFound";
                myCustomResponse.Message = "No firm was found incoming ip address";
                Response.Write(JsonConvert.SerializeObject(myCustomResponse));
                Response.StatusCode = (int)HttpStatusCode.Forbidden;
                Response.ContentType = "application/json";
                //Response.Flush() //it seems this line gives always ECONNRESET 
                return;
            }
            //..rest of code
        }
    }

}catch (Exception ex){
    MyCustomResponse myCustomResponse = new MyCustomResponse();
    myCustomResponse.Code = "ErrorOccured";
    myCustomResponse.Message = "Some Error Occured";
    Response.Write(JsonConvert.SerializeObject(myCustomResponse));
    Response.StatusCode = (int)HttpStatusCode.InternalServerError;
    Response.ContentType = "application/json";
    return; 
}

在邮递员处,当我向“PostSomeAction”发布操作时,它会不时地给 ECONNRESET 时间并有时返回 json 消息。

似乎当我取消注释 Response.Flush() 时,它似乎总是 ECONNRESET 但不确定。

另一方面,可能在 catch 执行中的 I 代码处,它成功返回 json 消息。

最后,当代码到达末尾没有任何“返回”时,它似乎总是成功返回 json 消息

在上述情况下,邮递员收到 ECONNRESET 消息的原因是什么?如果 ssl 是问题,它不应该总是出错。怎么可能“回归”表达因素呢?

标签: c#asp.netpostmanhttpresponse

解决方案


问题似乎与邮递员完全相关。使用 curl 从未发生过类似的问题。

要使用 curl 执行此操作,只需在描绘的图片中执行此操作:

在此处输入图像描述

在此处输入图像描述


推荐阅读