problem with kernel creation in vscode while connected to remote jupyter server? - jupyter-notebook

I am trying to connect to remote jupyter server which is running in remote server inside a docker. from vs code (local machine) with the help of jupyter extension, and running a newly created notebook.
The problem seems to be the kernel creation via this method for this newly created notebook.
My Jupyter Server is running in remote server, inside a docker environment, with port forwarding enable.
I can access it via my browser by http://{remote_machine_ip}:{port}/, and I am able to create new jupyter notebook.
However when I use the vs code to open local notebook file, and connect to the remote jupyter server.
When I try to run the cells, it shows the following error:
Failed to start the Kernel.
'_xsrf' argument missing from POST.
View Jupyter log for further details.
Possible solution
However, if I try to open a new kernel in browser, and connect it to same kernel in vs code, the problem goes away.

This issue seems to be arising when vs code sends the request to create jupyter kernel to the jupyter server.
As, when I tested with already running jupyter kernel in vs code, it works fine.
The issue here is, security implementation of jupyter server, which don't allow cross site request to create a kernel, as it security vulnerability.
For more details about _xsrf token, you can read here, although it doesn't talk about specific to jupyter server, its very easy to deduce the logic.
In one post of jetbrains, I found the solution, to make jupyter ignore _xsrf token, by adding new flag while starting the jupyter server,
--NotebookApp.disable_check_xsrf=True
Or add it to your notebook config.
Also, to make sure your request are not been blocked, as suggested by vscode blog. Add the following flag too,
--NotebookApp.allow_origin='*'

Related

How Jupyter extension in VSCODE acess remote Ipynb file when you Jupyter remote server

When you running a Jupyter notebook server on remote, your pc connect remote Jupyter server. You could use remote conda environemnt, remote intepreter.
One thing is different with Notebook(website version), you could not access remote ipynb file.
some many people just create a new blank notebook file and code it on it, but what I need is samething website version of notebook
Did anyone know how to do that?
I try to use SSH(remote devepolyment), it meet so many error and problem, I give up.

Kubeflow: Notebook server stuck on loading

Whenever I try to create a Kubeflow notebook server to build a pipeline from a jupyter notebook, it keeps loading forever without displaying any error.
I'm currently using a Kubeflow dashboard that's already up and running on a server, so I didn't deploy it myself and I'm not working on a local instance to use the terminal.
Any idea what the origin of the problem might be and how to solve it?
Here's a screenshot that might explain better.

jupyter notebook can't be saved from the remote access

I run a jupyter notebook which can access from the remote IP on our lab server(Of course I visited from the intranet of the school). And everything seems ok.
However, when I create a test.ipynb from the remote IP and write sth and save finally, nothing happens but autosave failed.
But the question is I can access the jupyter server from the lab server via localhost like.
And the save operation work!
I don't know why this happens??
I've tried to use chomd to add permissions, but it doesn't work.
And I've tried to use a docker to provide jupyter server, but it doesn't work either.
It seems to encounter some network problems that I never meet before.
Is that sth wrong with the lab server?

Access to Jupyter notebook from outside - How to allow google colab to access a local host Jupyter notebook?

I am trying to connect from google colab to local host - it does not work,
google troubleshooting advise suggests that I should allow local Jupyter notebook to accept colab requests - how to do it ?
Screenshot from local host which confirms that requests from colab are forbidden.
There should be some config modification to allow such requests, is not it ?
Advise from colab:
How I fixed my connection issues:
If after the above commands don't work, what finally did it for me was creating a firewall rule for port 8888.
Another big one that is in the instructions in your command line but not stated on the provided Google tutorial that some people will miss is that you need to open the URL in your browser that's given to you after launching Jupyter in order for it to create the access cookie and make it valid (sort of speak).
From the screenshot you provided, make sure you have "http://localhost:8888/?token=2534..." opened in your browser that is logged in with the same account accessing colab before it will allow access to colab (a separate window or tab will usually pops up on it's own when you run the command though).
Alternatively, you can also add the --no-browser tag to prevent the need to open it in your browser
Other solutions that involve installation issues to mitigate network issues:
There were a number of other troubleshooting steps that were particular to me but dont know if will apply to you but did you have any issues when installing Jupyter?
For me, even though jupyter would still launch, there were errors when installing on Windows, and to fix those I had to replace pip with pipwin and go through the steps that way.
For example
pipwin install jupyterlabs
pipwin install jupyter_http_over_ws
And in case it helps anyone else coming across this in the future, if you're using the DOS cmd line and have issues launching jupyter, replace the "" with a "^" to indicate continuation
i.e.:
jupyter notebook --NotebookApp.allow_origin="https://colab.research.google.com" --port=8888 --NotebookApp.port_retries=0

Can cloud instances of Jupyter Lab support pop out interactive windows

I'm new to Jupyter notebooks/Lab and I've successfully got interaction with pop-out windows and buttons etc with ipywidgets on local instances of Jupyter Lab but not in the cloud when using notebooks.ai - the code runs without error but doesn't create the appropriate windows/button.
Is there anyway to get this working or is this an inherent restriction of using Jupyter Lab in the cloud?
I'm wondering whether there are firewall settings that need configuring to get this to work?
The X11 forwarding is disabled on the docker machines provided by notebooks.ai. Hence, any pop-up interaction is not being forwarded to your machine. However, you can see any inline plot/button in the Jupyter notebook.
If you are interested in this feature there is a GitHub repository to request features (I have never tried it) but might be interesting for you to receive a more in-depth explanation, workaround, or solution.
PROVE:
In the launcher tab you can either run a notebook, a python interpreter or a terminal on the remote docker machine. If you select the terminal and type echo $DISPLAY, you will see that the result is an empty line (if a valid display was attached you will see something like: DISPLAY=localhost:11.0).
For further information about using BASH to check if X11 forwarding is enabled from SSH check this question.

Resources