首页 > 解决方案 > 无法通过 AJAX 调用识别“err_connection_reset”的原因

问题描述

2月11日更新

运行 ASP.NET MVC 网站。在这一点上,我们有一页有多个 AJAX GET 和一个用户发起的 AJAX POST 返回到我们的服务器。对于一小部分用户(但数量很大),他们的 POST 获得了“err_connection_reset”。这似乎发生在多个浏览器中,并且似乎是最近出现的现象。

但是,我们无法在内部使用任何浏览器(使用全球客户端计算机)复制此内容。我们也有数以万计的用户,这对他们来说非常有效。

我们很幸运有一位用户能够从 Chrome 的开发者工具中向我们提供一些详细信息:

a - 控制台显示 POST 的错误,仅显示“net::ERR_CONNECTION_RESET”

b - 从记录的 HAR 文件中,我们可以看到此事件的详细信息(部分数据替换为 ***):

{
"startedDateTime": "2020-02-07T19:09:32.786Z",
"time": 0.06441399999312125,
"request": {
    "method": "POST",
    "url": "http://****.*********.***/************/************",
    "httpVersion": "",
    "headers": [
        {
            "name": "Host",
            "value": "****.*********.***"
        },
        {
            "name": "Connection",
            "value": "keep-alive"
        },
        {
            "name": "Content-Length",
            "value": "864"
        },
        {
            "name": "Accept",
            "value": "*/*"
        },
        {
            "name": "X-Requested-With",
            "value": "XMLHttpRequest"
        },
        {
            "name": "User-Agent",
            "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
        },
        {
            "name": "Content-Type",
            "value": "application/json"
        },
        {
            "name": "Origin",
            "value": "http://****.*********.***"
        },
        {
            "name": "Referer",
            "value": "http://****.*********.***/************?************"
        },
        {
            "name": "Accept-Encoding",
            "value": "gzip, deflate"
        },
        {
            "name": "Accept-Language",
            "value": "en-US,en;q=0.9"
        },
        {
            "name": "Cookie",
            "value": "************"
        }
    ],
    "queryString": [],
    "cookies": [
        {
            "name": "************",
            "value": "************",
            "expires": null,
            "httpOnly": true,
            "secure": false
        }
    ],
    "headersSize": -1,
    "bodySize": 864,
    "postData": {
        "mimeType": "application/json",
        "text": "************"
    }
},
"response": {
    "status": 0,
    "statusText": "",
    "httpVersion": "",
    "headers": [],
    "cookies": [],
    "content": {
        "size": 0,
        "mimeType": "x-unknown"
    },
    "redirectURL": "",
    "headersSize": -1,
    "bodySize": -1,
    "_transferSize": 0,
    "_error": "net::ERR_CONNECTION_RESET"
},
"cache": {},
"timings": {
    "blocked": 0.06441399999312125,
    "dns": -1,
    "ssl": -1,
    "connect": -1,
    "send": 0,
    "wait": 0,
    "receive": 0,
    "_blocked_queueing": -1
},
"serverIPAddress": "",
"_initiator": {
    "type": "script",
    "stack": {
        "callFrames": [
            {
                "functionName": "send",
                "scriptId": "301",
                "url": "http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",
                "lineNumber": 1,
                "columnNumber": 80265
            },
            {
                "functionName": "ajax",
                "scriptId": "301",
                "url": "http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",
                "lineNumber": 1,
                "columnNumber": 77117
            },
            {
                "functionName": "n.ajax",
                "scriptId": "303",
                "url": "http://****.*********.***/bundles/************",
                "lineNumber": 0,
                "columnNumber": 2482
            },
            {
                "functionName": "************.************",
                "scriptId": "254",
                "url": "http://****.*********.***/bundles/************",
                "lineNumber": 0,
                "columnNumber": 69415
            },
            {
                "functionName": "************.************",
                "scriptId": "254",
                "url": "http://****.*********.***/bundles/************,
                "lineNumber": 0,
                "columnNumber": 67115
            },
            {
                "functionName": "dispatch",
                "scriptId": "301",
                "url": "http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",
                "lineNumber": 1,
                "columnNumber": 41771
            },
            {
                "functionName": "y.handle",
                "scriptId": "301",
                "url": "http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",
                "lineNumber": 1,
                "columnNumber": 39790
            }
        ]
    }
},
"_priority": "High",
"_resourceType": "xhr",
"pageref": "page_1"
}

从计时部分来看,该调用似乎被阻塞了大约 64 微秒(可能在其他 AJAX 调用之后),但它未能排队并且从未发送。

我没有看到a)会导致这种情况的原因以及b)如何更深入地研究这一点。有什么建议么?

更新:2月11日

在分析更大的 HAR 文件时,我可以看到它只影响 Content-Type 为“application/json”的 POSTS。

标签: ajaxgoogle-chromebrowserharconnection-reset

解决方案


推荐阅读