Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome hangs after certain amount of data transfered - waiting for available socket

I've got a browser game and I have recently started adding audio to the game.

Chrome does not load the whole page and gets stuck at "91 requests | 8.1 MB transferred" and does not load any more content; and it even breaks the website in all other tabs, saying Waiting for available socket.

After 5 mins (exactly) the data are loaded.

enter image description here

enter image description here

This does not happen on any other browser.

Removing one MP3 file (the latest added one) fixed the problem, so is it perhaps a data limit problem?

like image 250
Foxhoundn Avatar asked May 15 '14 13:05

Foxhoundn


People also ask

How do I flush a chrome socket?

To flush the socket pools, go to chrome://net-internals/#sockets and click Flush socket pools. If you are already on the DNS page, just select Sockets in the left hand column. Usually you don't need to worry about flushing the socket pools.

Why does it say waiting for cache?

The cache is that place where your internet browser, in this case, Google Chrome, stores certain information about your browsing activity so it can access regularly used websites quicker. The waiting for cache error you see on your laptop or computer occurs when Chrome is unable to access this information.

What is Chrome net internals?

What is net-internals? Per the Chromium Project, Net-internals is a “visualizer for the NetLog event stream. It can be used both in real-time, and also to load up post-mortem NetLog dumps.” Essentially, it's a real time look at network data, allowing you to download logs and see visuals of network data.


2 Answers

Explanation:

This problem occurs because Chrome allows up to 6 open connections by default. So if you're streaming multiple media files simultaneously from 6 <video> or <audio> tags, the 7th connection (for example, an image) will just hang, until one of the sockets opens up. Usually, an open connection will close after 5 minutes of inactivity, and that's why you're seeing your .pngs finally loading at that point.

Solution 1:

You can avoid this by minimizing the number of media tags that keep an open connection. And if you need to have more than 6, make sure that you load them last, or that they don't have attributes like preload="auto".

Solution 2:

If you're trying to use multiple sound effects for a web game, you could use the Web Audio API. Or to simplify things, just use a library like SoundJS, which is a great tool for playing a large amount of sound effects / music tracks simultaneously.

Solution 3: Force-open Sockets (Not recommended)

If you must, you can force-open the sockets in your browser (In Chrome only):

  1. Go to the address bar and type chrome://net-internals.
  2. Select Sockets from the menu.
  3. Click on the Flush socket pools button.

This solution is not recommended because you shouldn't expect your visitors to follow these instructions to be able to view your site.

like image 132
Marquizzo Avatar answered Oct 01 '22 04:10

Marquizzo


Looks like you are hitting the limit on connections per server. I see you are loading a lot of static files and my advice is to separate them on subdomains and serve them directly with Nginx for example.

  • Create a subdomain called img.yoursite.com and load all your images from there.

  • Create a subdomain called scripts.yourdomain.com and load all your JS and CSS files from there.

  • Create a subdomain called sounds.yoursite.com and load all your MP3s from there... etc..

Nginx has great options for directly serving static files and managing the static files caching.

like image 35
Predte4a Avatar answered Oct 01 '22 04:10

Predte4a