src/utils/NodeConnection.js
function doConnect() {
            attemptCount++;
            attemptTimestamp = new Date();
            attemptSingleConnect().then(
                registerHandlersAndDomains, // succeded
                function () { // failed this attempt, possibly try again
                    if (attemptCount < CONNECTION_ATTEMPTS) { //try again
                        // Calculate how long we should wait before trying again
                        var now = new Date();
                        var delay = Math.max(
                            RETRY_DELAY - (now - attemptTimestamp),
                            1
                        );
                        setTimeout(doConnect, delay);
                    } else { // too many attempts, give up
                        deferred.reject("Max connection attempts reached");
                    }
                }
            );
        }
function doConnect() {
            attemptCount++;
            attemptTimestamp = new Date();
            attemptSingleConnect().then(
                registerHandlersAndDomains, // succeded
                function () { // failed this attempt, possibly try again
                    if (attemptCount < CONNECTION_ATTEMPTS) { //try again
                        // Calculate how long we should wait before trying again
                        var now = new Date();
                        var delay = Math.max(
                            RETRY_DELAY - (now - attemptTimestamp),
                            1
                        );
                        setTimeout(doConnect, delay);
                    } else { // too many attempts, give up
                        deferred.reject("Max connection attempts reached");
                    }
                }
            );
        }
function doConnect ( ) { attemptCount ++ ; attemptTimestamp = new Date ( ) ; attemptSingleConnect ( ) . then ( registerHandlersAndDomains , // succeded function ( ) { // failed this attempt, possibly try again if ( attemptCount < CONNECTION_ATTEMPTS ) { //try again // Calculate how long we should wait before trying again var now = new Date ( ) ; var delay = Math . max ( RETRY_DELAY - ( now - attemptTimestamp ) , 1 ) ; setTimeout ( doConnect , delay ) ; } else { // too many attempts, give up deferred . reject ( "Max connection attempts reached" ) ; } } ) ; }
Repeatedly tries to connect until we succeed or until we've failed CONNECTION_ATTEMPT times. After each attempt, waits at least RETRY_DELAY before trying again.
Repeatedly tries to connect until we succeed or until we ve failed CONNECTION_ATTEMPT times . After each attempt waits at least RETRY_DELAY before trying again .