Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to load resource: net::ERR_NETWORK_IO_SUSPENDED

I searched Stack Overflow and Google for the specific error message in the title, but I did not find it (in the context of JavaScript coding, not browser settings). On my site, there are five functions that are called every 10 seconds. These functions do things such as:

  1. Check the user's inbox for new emails
  2. Check the user's account for new instant messages
  3. etc.

However, if the user is logged in, but is INACTIVE (does not use the mouse or press any keys) for about 15 minutes, I get the following error message when I "Inspect Element" with Chrome:

Failed to load resource: net::ERR_NETWORK_IO_SUSPENDED // (x 5)
Uncaught Type Error: Cannot read property 'combinedfiletimeinput' of undefined //one of my previously defined form values is now not defined

At this point, the user's new email count, new IM count, etc. go blank (whereas they were integers before). All the user has to do is refresh the page or go to another page to reconnect, so it's not a huge deal.

My hack solution is to use a JavaScript timer to automatically logout the user if there is not any of the following events in a 15 minute period:

  1. Mouse click
  2. Mouse movement
  3. Key press

Is there a way to prevent this "Failed to load resource" error from occurring?

UPDATE: This seems to occur when the user's device sleeps/hibernates while still logged on...when the user restarts the device. This is when the error message can be seen on Chrome's Inspect Element, Firebug, etc.

UPDATE 10/02/2014: I have now condensed the five setTimeout functions into one large setTimeout function. In addition, the form that held the modify times in an input called "combinedfiletimeinput" has been removed and I now handle the file modify times differently.

Here is a screenshot of the Chrome Developer Tools log showing the error. I have added "mysite" in place of my site's name and "filename" in place of the actual filename. I have also whited out the name of the external JavaScript file, and all that remains is .js (sorry, but I'm just trying to be careful :) ) I cut off some of the screenshot, so the text would be large enough to read.

Chrome Screenshot

As you can see by the screenshot, the request processes OK for the first three requests. Then I "sleep"ed my device and then turned my device back on. That's where the next two requests are errors (in red). After these first two errors, the requests begin to process normally again (rows with black text, after rows with red text). The console clearly shows the error message.

like image 506
The One and Only ChemistryBlob Avatar asked May 18 '14 17:05

The One and Only ChemistryBlob


People also ask

How do I fix failed to load resources?

Chrome's cache clearing process, check all the options, and set the time range to “All time.” After you've cleared your cache, this might reset any options that were producing the error. Check the page in question to see if the resource is now displaying correctly. If not, you can also try resetting Chrome flags.

What is network IO suspended?

1-Network access suspended. Unable to load the webpage because your computer entered sleep or hibernate mode. When this happens, network connections are shut down and new network requests fail.


2 Answers

Just summarizing my comments under the question for community.

After some testing, it seems, that setting Ajax timeouts for every call is a must. Without timeouts, NET:: errors such as ERR_NETWORK_IO_SUSPENDED, ERR_INTERNET_DISCONNECTED, etc will cause Ajax to stop execution, and would not resume after computer wake up.

For jQuery:

$.ajax({
   url: yourURL,
   timeout: 4000
});

For XMLHttpRequest (XHR):

 xhr.timeout = 4000;

Moreover, an exception handler is necessary for your script to catch connection errors, so that your JavaScript code would not break down because of unexpected behavior/values.

Even with timeouts and exeption handler, your application will throw NET:: errors, but they would not harm your application; you could think of them as Notices.

like image 116
Adam Fischer Avatar answered Oct 19 '22 00:10

Adam Fischer


As much as I think catching exceptions should be the general cure, you might try triggering fake (mouse, scroll, keyboard) events to see if that would prevent Chrome from going to "idle" status.

Stack Overflow question How to simulate a mouse click using JavaScript? might be helpful.

like image 1
ptrk Avatar answered Oct 19 '22 02:10

ptrk