Skip to content

If a notebook loses its network connection WebSockets won't reconnect #1577

Closed
ellisonbg opened this Issue Apr 12, 2012 · 5 comments

4 participants

@ellisonbg
IPython member

If a computer running the notebook client in a browser loses its network connection to the notebook server, it is unable to later reconnect after the connection is reestablished. The non WebSocket connections work fine, but we need to add custom logic that auto-reconnects the WebSockets.

@invisibleroads

I added a quick workaround for the time being.
invisibleroads/ipython@9995f2a

Kernel.prototype._websocket_closed = function(ws_url, early){
    var msg;
    var parent_item = $('body');
    if (early) {
        msg = "Websocket connection to " + ws_url + " could not be established." +
        " You will NOT be able to run code." +
        " Your browser may not be compatible with the websocket version in the server," +
        " or if the url does not look right, there could be an error in the" +
        " server's configuration.";
    } else {
        this._handle_start_kernel({
            ws_url: ws_url,
            kernel_id: this.kernel_id
        }, $.proxy(IPython.notebook.kernel_started, IPython.notebook));
        return;
    }
@invisibleroads

The following quickfix does resolve the issue, although it's not pretty because it references IPython.notebook inside kernel.js, which doesn't follow the convention where such references are only in notebook.js
invisibleroads/ipython@d9c55ca

    if (early) {
        msg = "Websocket connection to " + ws_url + " could not be established." +
        " You will NOT be able to run code." +
        " Your browser may not be compatible with the websocket version in the server," +
        " or if the url does not look right, there could be an error in the" +
        " server's configuration.";
    } else {
        this._handle_start_kernel({
            ws_url: this.ws_url,
            kernel_id: this.kernel_id
        }, $.proxy(IPython.notebook.kernel_started, IPython.notebook));
        return;
    }
@ellisonbg
IPython member
@invisibleroads

Please let me know when the branch referenced in #1711 is merged. There are other user interface enhancements that I would like to make.

@Carreau
IPython member
Carreau commented Jun 1, 2012

Please let me know when the branch referenced in #1711 is merged. There are other user interface enhancements that I would like to make.

@invisibleroads , #1711 has been merged a few hours ago.

@fperez fperez closed this in 41f79e7 Jun 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.