Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple HTML5 Websockets - when one connection fails all remaining websocket connections are delayed
    primarykey
    data
    text
    <p>I have a project that uses multiple HTML5 websocket connections on the same page. When all connections are available, the page functions as expected. However, when one or more of the websocket connections are down, all remaining connections are blocked until the bad connection times out. After timeout, the remaining websockets connect as expected.</p> <p>Note the <code>uris</code> array below. I have purposely added a bad websocket address to re-create this issue. When the <code>each</code> loop fires, the first uri connects immediately and updates a <code>li</code> tag in the html. The browser then hangs on the second (bad) uri for as long as 60 seconds before finally moving to the third uri which also connects immediately.</p> <p>I was able to re-create this issue here: <a href="http://jsfiddle.net/eXZA6/2/" rel="nofollow">http://jsfiddle.net/eXZA6/2/</a></p> <p>Javascript</p> <pre><code>var uris = { '1': 'ws://echo.websocket.org/', '2': 'ws://echo.websocket.org:1234/', //Bad websocket address '3': 'ws://echo.websocket.org/' }; var sockets = {}; $.each(uris, function(index, uri) { sockets[index] = connect(index, uri); }); function connect(index, uri) { var websocket = new WebSocket(uri); websocket.onopen = function (evt) { $('li#' + index).text('Connected'); }; websocket.onclose = function (evt) { $('li#' + index).text('Closed'); }; websocket.onmessage = function (evt) { $('li#' + index).text('Received: ' + evt.data) }; websocket.onerror = function (evt) { $('li#' + index).text('Error'); }; return websocket; } </code></pre> <p>HTML</p> <pre><code>&lt;ul id="connection"&gt; &lt;li id="1" /&gt; &lt;li id="2" /&gt; &lt;li id="3" /&gt; &lt;/ul&gt; </code></pre> <ul> <li>I tried using setTimeout and other hacky multi-thread tricks with no luck.</li> <li>Oddly enough, the functionality I expected appears to work in IE10, but not Firefox or Chrome.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload