javascript 无法加载资源:net::ERR_EMPTY_RESPONSE http://test.com

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22374328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 23:01:24  来源:igfitidea点击:

Failed to load resource: net::ERR_EMPTY_RESPONSE http://test.com

javascripthtmlajaxgoogle-chrome-extension

提问by Kevin

Im working on a chrome extension which sends XMLHttpRequest to a URL, gets response in JSON format, parse the response and shows list of records. Its working fine. The problem is when user performs any action and go back to listing section, system follows the same process sends the XMLHttpRequest request but everytime i get this response:

我正在开发一个 chrome 扩展,它将 XMLHttpRequest 发送到一个 URL,以 JSON 格式获取响应,解析响应并显示记录列表。它的工作正常。问题是当用户执行任何操作并返回列表部分时,系统遵循相同的过程发送 XMLHttpRequest 请求,但每次我收到此响应时:

Failed to load resource: net::ERR_EMPTY_RESPONSE http://test.com

First time when i load the extension everything works fine, after that it always show the above mentioned error.

第一次加载扩展时一切正常,之后总是显示上述错误。

Its a two HTML pages extension. One for signin and other for listing. Im using ajax to toggle divs based on results.

它是一个两个 HTML 页面扩展。一个用于登录,另一个用于列表。我使用ajax根据结果切换div。

Now the Weird part. Only 3 of my users have this problem so far. Two of them have mac and one windows 8.1. For all other users it works perfectly fine.

现在是奇怪的部分。到目前为止,我的用户中只有 3 个有这个问题。其中两个有 mac 和一个 windows 8.1。对于所有其他用户,它工作得很好。

回答by Sablefoste

I have run across the same problem. I developed a very AJAX intensive application, which works perfectly on the localhost. Using the identical machine to test the live site (hosted by GoDaddy) pressing a button to activate an AJAX function is intermittently accepted.

我遇到了同样的问题。我开发了一个 AJAX 密集型应用程序,它在本地主机上运行良好。使用相同的机器来测试实时站点(由 GoDaddy 托管)按下按钮以激活 AJAX 功能被间歇性地接受。

If I repeatedly press the button, and watch what is going on in the developer tools, I see the Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.indicated by the "(failed)":

如果我反复按下按钮,并观察开发人员工具中发生的事情,我会看到Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.“(失败)”指示:

enter image description here

在此处输入图片说明

On the eighth attempt in the above picture, you can see it finally worked. The best way to verify if this is what is happening to you is to wait 1 minute, and repeat the action.It seems that the speed of the connection is what is causing this problem, although the speed of the last error is much faster than the first success. And while I am checking other websites to verify that the internet is still "ON", this might do more with the settings in the web-browser, or the host computer. You can see that this seems to be the solution to the problem, according to this answer. But then again, this answerstates to reset the network settings and restart the machine.

在上图中的第八次尝试中,您可以看到它终于成功了。验证这是否是您正在发生的事情的最佳方法是等待 1 分钟,然后重复该操作。看来连接的速度是导致这个问题的原因,虽然最后一次错误的速度比第一次成功要快得多。虽然我正在检查其他网站以验证互联网是否仍处于“开启”状态,但这可能对网络浏览器或主机中的设置有更多作用。根据这个答案,您可以看到这似乎是解决问题的方法。但是话又说回来,这个答案声明重置网络设置并重新启动机器。

Other solutions point to clearing the browser's cache or disabling add-ons, but reloading or refreshing is difficult and unreliable as a solution for non-tech users. Finally, it might have something to do with the hosting server settings.

其他解决方案指向清除浏览器的缓存或禁用加载项,但重新加载或刷新作为非技术用户的解决方案既困难又不可靠。最后,它可能与托管服务器设置有关

I suspect it may have something to do with the Server sensing a DDOS attack (a large number of small AJAX requests), so it temporarily blocks/ignores the request. Changing hosts (or self hosting) may be the best solution.

我怀疑这可能与服务器感知 DDOS 攻击(大量小型 AJAX 请求)有关,因此它会暂时阻止/忽略该请求。更改主机(或自托管)可能是最好的解决方案。