Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter notebook run in chrome gets stuck on server restart #3764

Open
stas00 opened this issue Jul 13, 2018 · 5 comments
Open

Jupyter notebook run in chrome gets stuck on server restart #3764

stas00 opened this issue Jul 13, 2018 · 5 comments

Comments

@stas00
Copy link

stas00 commented Jul 13, 2018

I start with a working jupyter setup, and everything works just fine. I can interrupt or restart the kernel from the notebook without any problems.

If, however, I change some jupyter configuration, or install some modules, and restart jupyter server - I have to wait for about 5 minutes for the open notebooks to recover access to the python kernel.

To reproduce the problem:

  1. Start jupyter (local shell)

    jupyter notebook

  2. In chrome create a new notebook (python 3), which will result in a url like:

    http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3

  3. Create and run a single cell in that new notebook:

    print(1)

  4. Restart jupyter (Ctrl-C followed by [yes] to the prompt to exit), followed by:

    jupyter notebook

  5. Go to the same chrome tab with the same single cell notebook and click OK for the pop-up "Connection failed"

  6. Observe the notebook showing: [Connecting to Kernel] without success.

  7. Try to Restart the kernel via the menu, usually it gets stuck in [Kernel Starting...], and after several manually forced kernel restarts it supposedly succeeds [Kernel Created], but it's a false success, as trying to run the cells gives a [*] busy sign and nothing happens.

After some 5 min of waiting it recovers by itself.

Workarounds:

  • Reloading the notebook in the browser (i.e. hitting Reload at the browser level)
  • Restarting chrome, can add a bookmarklet with chrome://restart/ to make it into 1-click restart.

Software:

  • ubuntu 18.04
  • notebook 5.7.4
  • python 3.7.1
  • chrome 71
  • no adblock software enabled
  • empty ~/.jupyter (removed everything for the sake of the testing, so no extensions or custom configuration)

Same setup works fine in firefox on the same machine.

There are several tickets on github about the same from 2015 (e.g. #1415, but somehow they blame it on chrome and clearly the issue is still there 3 years later).

Any idea how to solve this?

Thank you.

And here is the log during the open notebook reconnect/restart process:

[I 22:54:09.032 NotebookApp] Kernel restarted: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:54:09.343 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:54:45.348 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:55:37.359 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:57:01.367 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[I 22:57:41.337 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:57:41.350 NotebookApp] Replacing stale connection: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:41.352 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.324 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.327 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:49.328 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6

edit: updated my setup specs to the current ones.

@maartenbreddels
Copy link
Contributor

maartenbreddels commented Jul 16, 2018

I have this a lot, restarting the notebook with tabs open and restarting the notebook servers makes it difficult for the notebooks to get a kernel again. I think this also happened to @SylvainCorlay at SciPy 2018.
I can often fix this by closing all tabs, then restarting the notebook server.
On OSX with Chrome, saw the same on Linux with Firefox with a colleague.

@MaxGhenis
Copy link

I think I'm hitting a similar issue: when running a notebook, at one point (when producing matplotlib graphs) the server says "Starting buffer for..." and then the connection drops. The server still thinks it's fine, but in Chrome I get "ERR_CONNECTION_REFUSED." At this point I'm unable to connect to localhost for anything, including a restarted Jupyter server and a basic HTML server as suggested in #1832 (comment).

The only remedy I've found is to reboot my device, but it continues to happen at the same stage of the notebook consistently. I'll try closing other tabs.

I'm running ChromeOS's native Linux environment, Jupyter 1.0.0 on Python 3.7 via conda.

@stas00
Copy link
Author

stas00 commented Dec 21, 2018

The issue is still there. Any chance someone could look at it?

Last time it was discussed here and was closed unresolved. #1415 Some people had an issue with ublock, but this is not the case - it's the same problem w/ or w/o ublock.

@Amini-ML
Copy link

Amini-ML commented Apr 21, 2020

  1. Create a configuration file for Jupyter notebook by:
    a@admin:~$ jupyter notebook --generate-config

  2. open the config file by a text editor and find:
    c.NotebookApp.use_redirect_file = True

  3. Set the value to False then uncomment the line and save

@stas00
Copy link
Author

stas00 commented Apr 29, 2020

Thank you for this update, @Amini-ML

With this change it seems to work most of the time if after restarting the jupyter server, the URL of the notebook is reloaded in the browser. There were a few instances where it was still stuck. I will test more with real notebooks.

If however I don't reload the URL in the browser, and restart the jupyter server, followed by kernel restart, it says the kernel has been restarted, but the notebook won't run, all cells are (*) busy. Probably it shouldn't say the kernel has been restarted if in fact it's not functional.

For other linux/chrome users who may read this, the config file is ~/.jupyter/jupyter_notebook_config.py and you will need jupyter-notebook >= 6.0.3 for this to work. (at least it didn't with 6.0.1) and of course, you will need to restart the jupyter server after changing the config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants