Skip to content

Commit

Permalink
Doing linear backoff after failures
Browse files Browse the repository at this point in the history
  • Loading branch information
cramforce committed Oct 9, 2010
1 parent 9e91e73 commit fbd762c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion public/lib/stream/client.js
Expand Up @@ -29,7 +29,19 @@ require.def("stream/client",
return transports;
}

function connect (cb) {
function connect(cb) {
var wait = (connectFail < 0 ? 0 : connectFail) * 1000;
var max = 30 * 1000;
if(wait > max) {
wait = max;
}
console.log("[Connect] waiting for "+wait);
setTimeout(function () {
_connect(cb)
}, wait);
}

function _connect(cb) {
window.WEB_SOCKET_SWF_LOCATION = "/foobar"; // we do not use flash, but socket.io still complaints
var socket = new io.Socket(location.hostname, {
port: location.port || 80,
Expand Down

0 comments on commit fbd762c

Please sign in to comment.