diff --git a/IPython/html/static/notebook/js/notificationarea.js b/IPython/html/static/notebook/js/notificationarea.js
index 188144e0d..002e4b1b8 100644
--- a/IPython/html/static/notebook/js/notificationarea.js
+++ b/IPython/html/static/notebook/js/notificationarea.js
@@ -175,37 +175,35 @@ define([
});
this.events.on('status_disconnected.Kernel', function () {
- knw.danger("Disconnected", undefined, function () {
- that.notebook.kernel.reconnect();
- return false;
- });
$kernel_ind_icon
.attr('class', 'kernel_disconnected_icon')
.attr('title', 'No Connection to Kernel');
});
- this.events.on('connection_failed.Kernel', function () {
- // hide existing dialog
- $(".modal").modal('hide');
-
- var msg = "A WebSocket connection could not be established." +
- " You will NOT be able to run code. Check your" +
- " network connection or notebook server configuration.";
-
- dialog.modal({
- title: "WebSocket connection failed",
- body: msg,
- keyboard_manager: that.keyboard_manager,
- notebook: that.notebook,
- buttons : {
- "OK": {},
- "Reconnect": {
- click: function () {
- that.notebook.kernel.reconnect();
- }
+ this.events.on('connection_failed.Kernel', function (evt, info) {
+ // only show the dialog if this is the first failed
+ // connect attempt, because the kernel will continue
+ // trying to reconnect and we don't want to spam the user
+ // with messages
+ if (info.attempt === 1) {
+ // hide existing dialog
+ $(".modal").modal('hide');
+
+ var msg = "A connection to the notebook server could not be established." +
+ " The notebook will continue trying to reconnect, but" +
+ " until it does, you will NOT be able to run code. Check your" +
+ " network connection or notebook server configuration.";
+
+ dialog.modal({
+ title: "Connection failed",
+ body: msg,
+ keyboard_manager: that.keyboard_manager,
+ notebook: that.notebook,
+ buttons : {
+ "OK": {}
}
- }
- });
+ });
+ }
});
this.events.on('status_killed.Kernel status_killed.Session', function () {
diff --git a/IPython/html/static/services/kernels/js/kernel.js b/IPython/html/static/services/kernels/js/kernel.js
index 4e60d091d..4e5035fe6 100644
--- a/IPython/html/static/services/kernels/js/kernel.js
+++ b/IPython/html/static/services/kernels/js/kernel.js
@@ -63,6 +63,7 @@ define([
this.last_msg_callbacks = {};
this._autorestart_attempt = 0;
+ this._reconnect_attempt = 0;
};
/**
@@ -116,6 +117,9 @@ define([
this.events.on('status_ready.Kernel', function () {
that._autorestart_attempt = 0;
});
+ this.events.on('status_connected.Kernel', function () {
+ that._reconnect_attempt = 0;
+ });
};
/**
@@ -517,12 +521,12 @@ define([
this.stop_channels();
this.events.trigger('status_disconnected.Kernel', {kernel: this});
- if (!error) {
- this.reconnect();
- } else {
+ if (error) {
console.log('WebSocket connection failed: ', ws_url);
- this.events.trigger('connection_failed.Kernel', {kernel: this, ws_url: ws_url});
+ this._reconnect_attempt = this._reconnect_attempt + 1;
+ this.events.trigger('connection_failed.Kernel', {kernel: this, ws_url: ws_url, attempt: this._reconnect_attempt});
}
+ this.reconnect();
};
/**