Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 8d8ec23

Browse files
committed
Always retry the connection, not only during the initial connection.
- shows a connecting message while connecting.
1 parent 03b8f10 commit 8d8ec23

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

js/start.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ var Polyglot = require('node-polyglot'),
5656
loadProfileNeeded = true,
5757
startUpConnectMaxRetries = 4,
5858
startUpConnectRetryDelay = 2 * 1000,
59-
startUpConnectMaxTime = 10 * 1000,
60-
startTime = Date.now(),
59+
//startUpConnectMaxTime = 10 * 1000,
60+
//startTime = Date.now(),
6161
startUpRetry,
6262
removeStartupRetry,
6363
onActiveServerSync,
@@ -527,6 +527,7 @@ $(document).ajaxSend(function(e, jqXhr) {
527527
});
528528

529529
$(document).ajaxError(function(event, jqxhr) {
530+
console.log("ajax error");
530531
if (jqxhr.status === 401 && jqxhr.serverConfig.id === app.serverConfigs.getActive().id) {
531532
app.serverConnectModal.failConnection('failed-auth', jqxhr.serverConfig)
532533
.open();
@@ -571,6 +572,7 @@ launchOnboarding = function(guidCreating) {
571572
})();
572573

573574
pageConnectModal.on('cancel', () => {
575+
console.log("page connect modal on cancel");
574576
removeStartupRetry();
575577
app.getHeartbeatSocket()._socket.onclose = null;
576578
app.getHeartbeatSocket().close();
@@ -596,7 +598,9 @@ app.serverConnectModal.on('connected', () => {
596598
app.getHeartbeatSocket().on('open', function() {
597599
removeStartupRetry();
598600
pageConnectModal.remove();
599-
startUpLoadingModal.open();
601+
//startUpLoadingModal.open();
602+
console.log("heartbeat open");
603+
this.retryConnectionMsg && this.retryConnectionMsg.remove();
600604

601605
if (!profileLoaded) {
602606
// clear some flags so the heartbeat events will
@@ -609,27 +613,44 @@ app.getHeartbeatSocket().on('open', function() {
609613
});
610614

611615
app.getHeartbeatSocket().on('close', startUpRetry = function() {
616+
console.log("heartbeat closed starupRetry");
617+
console.log(startUpConnectMaxRetries);
618+
/*
612619
if (
613620
Date.now() - startTime < startUpConnectMaxTime &&
614621
startUpConnectMaxRetries
622+
*/
623+
if (startUpConnectMaxRetries
615624
) {
616625
startUpRetry.timeout = setTimeout(() => {
626+
console.log("retry connection");
617627
startUpConnectMaxRetries--;
618628
app.connectHeartbeatSocket();
629+
this.retryConnectionMsg = this.retryConnectionMsg || app.statusBar.pushMessage({
630+
type: 'warning',
631+
msg: '<i>' + window.polyglot.t('retryingConnection') + '</i>',
632+
duration: false
633+
});
619634
}, startUpConnectRetryDelay);
620635
} else {
636+
console.log("connect retries exceeded");
637+
this.retryConnectionMsg && this.retryConnectionMsg.remove();
621638
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive())
622639
.open();
623640
}
624641
});
625642

626643
removeStartupRetry = function() {
644+
startUpConnectMaxRetries = 4;
645+
/*
627646
clearTimeout(startUpRetry.timeout);
628647
app.getHeartbeatSocket().off('close', startUpRetry);
629648
app.getHeartbeatSocket().on('close', () => {
649+
console.log("removeStartupRetry close")
630650
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive());
631651
632652
if (app.serverConnectModal.getConnectAttempt()) {
653+
console.log("get connect attempt")
633654
app.serverConnectModal.getConnectAttempt()
634655
.fail(() => {
635656
app.serverConnectModal.open();
@@ -638,6 +659,7 @@ removeStartupRetry = function() {
638659
app.serverConnectModal.open();
639660
}
640661
});
662+
*/
641663
};
642664

643665
app.getHeartbeatSocket().on('message', function(e) {

0 commit comments

Comments
 (0)