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

Remote kernel does not work after updating to Hydrogen 2.16.1 #2109

Closed
kuri54 opened this issue May 27, 2021 · 14 comments · Fixed by #2110 or #2118
Closed

Remote kernel does not work after updating to Hydrogen 2.16.1 #2109

kuri54 opened this issue May 27, 2021 · 14 comments · Fixed by #2110 or #2118
Labels
bug 🐛 For unexpected issues

Comments

@kuri54
Copy link

kuri54 commented May 27, 2021

macOS Big Sur 11.2.3
Atom 1.56.0 x64
Hydrogen 2.16.1

#2094 has been addressed and updated to Hydrogen 2.16.1.

I found a bug where the connection to the remote kernel did not work properly after the update.
Rolled back Hydrogen to 2.15.3 with apm, and confirmed that it works correctly.

I will try not to update until the issue is resolved.

@kuri54 kuri54 added the bug 🐛 For unexpected issues label May 27, 2021
@aminya
Copy link
Member

aminya commented May 27, 2021

Could you let me know how you use a remote kernel? The settings, the kernel you use, etc. This allows me to reproduce the issue and fix it.

@kuri54
Copy link
Author

kuri54 commented May 27, 2021

I apologize for the lack of words as I rushed the problem out.

Here's how I'm using it
・Access the analysis server via ssh.
・Boot the Jupyter kernel using Docker on the analysis server.
・Connect to the Jupyter kernel using ATOM Hydrogen: Connect To Remote Kernel.
・Connect to the Jupyter kernel using ATOM Hydrogen: Connect To Remote Kernel (set the IP address and token in Hydrogen Settings: Kernel Gateways)

The Hydorogen version 2.15.3 recognizes the kernel and reads the token with the above operations.

With version 2.16.1, I get an error (Forbidden, 403 GET・・・・・ referer=None) when connecting the kernel and the token is not recognized.

@aminya
Copy link
Member

aminya commented May 27, 2021

No worries. I will look into this. I can guess where the issue is coming from. It is probably because of using the new XMLHttpRequest dependency

@fohria
Copy link

fohria commented May 27, 2021

I think I have the same issue.

  • Running jupyterlab 3.0.14 on remote machine.
  • Connect to remote kernels with Hydrogen: Connect to Remote Kernel
  • Have set the details of remote machine in Hydrogen Settings: Kernel Gateways

I get as far as seeing the available environments/kernels but nothing happens when I try to select(press enter) on any of them.

Same Forbidden error as @kuri54 , and jupyter logs also say '_xsrf' argument missing from POST

2.15.3 works, 2.16.1 doesn't.

@kuri54
Copy link
Author

kuri54 commented May 27, 2021

The '_xsrf' argument missing from POST error itself is in ./home/jovyan/.jupyter/jupyter_notebook_config.py (if this file is not there, create it with $ jupyter notebook --generate-config).

I've tried that way, but Forbidden, 403 GET・・・・・ referer=None error could not be solved.
Either way, I think this bug is in Hydrogen as @aminya says.

There is not a day that goes by that I do not code in a remote environment myself. That's more important than exporting .ipynb files.

It looks like the cause is somewhat known, so until it is resolved, I'm waiting for an improved version to be released by rolling back using something like apm install Hydrogen@2.15.3.

@aminya
Copy link
Member

aminya commented May 28, 2021

I fixed it in the latest version. Let me know if it works for you too.

@kuri54
Copy link
Author

kuri54 commented May 28, 2021

Thank you for your quick response. It was very helpful.

I updated it immediately and confirmed that it works. So far it is working fine.

Thank you very much.

@fohria
Copy link

fohria commented May 28, 2021

Thanks for the quick response @aminya , I'm happy to see some love for Hydrogen :)

However...

I could connect to existing/already running kernel session with new version, but not create a new session. Still get the '_xsrf' argument missing from POST error, and that error doesn't show with 2.15.3.

That error seems to pop up when I click enter on any of the kernels/environments in the list of kernels/environments shown after I have pasted the token and selected to start a new session.

Found this old comment #922 (comment) (thanks @kuri54 for pointing me in its direction!)

I did not have a /home/username/.jupyter/jupyter_notebook_config.py file so I generated one with jupyter notebook --generate-config.

Following the instructions in the comment linked above, I then set the c.NotebookApp.token option in that file to a non empty string ('hello' in my case) and restarted jupyterlab on the remote machine. Weirdly, I didn't have to enter a token at all with that change, but still get '_xsrf' argument missing from POST error.

So I reset c.NotebookApp.token back to default and tried instead to set c.NotebookApp.disable_check_xsrf = True and restarted jupyterlab.

Now I still don't have to enter a token when connecting with hydrogen, but can select to start a new session and kernel/environment. But the status of the kernel (bottom left in atom window) gets stuck on "reconnecting" and the jupyterlab logs say Couldn't authenticate WebSocket connection.

Which makes sense I guess since I for some reason don't have to give a token now.

I reset c.NotebookApp.disable_check_xsrf to default and restarted jupyterlab and still don't get asked for token, even after restarting atom and downgrading/reinstalling 2.16.2, so not sure what's going on here.

Downgraded to 2.15.3 and everything works fine again.

@aminya
Copy link
Member

aminya commented May 28, 2021

The reason for this error might be that I switched to the native XMLHttpRequest when you use a token. If you select "cookies" still the old behavior is used because that is a non-standard way.

I can switch everything to the old behavior, but not sure if that is a good idea (?). The error might be there for a reason.

People are reporting that refreshing the server has solved the issue...
#922 (comment)

@kuri54
Copy link
Author

kuri54 commented May 28, 2021

Just to be sure, I'll add my environment to the list.

First, I commented out c.NotebookApp.disable_check_xsrf in /home/username/.jupyter/jupyter_notebook_config.py.

Next, we set up the token for JupyterNotebook in the Dockerfile. (ex. CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--no-browser", "--NotebookApp.token"])
IIn addition, by configuring the Hydrogen Kernel Gateways as [{"name": "Remote", "options": {"baseUrl": "http://mysite:8888", "token": "mytoken"}}], you will not need to enter the token every time.

After updating to 2.16.2 with this setting, it works fine.

@fohria
Copy link

fohria commented May 29, 2021

Aha, okay, it works when I set the token in Hydrogen settings Kernel Gateways as you did @kuri54

So what I've always done before is I've just started jupyter lab, copied the auto generated token, and then used that in the interactive prompt in Hydrogen/Atom when connecting.

It seems that with the changes in 2.16.2 the interactive prompt for a token doesn't work anymore, but if I paste the auto generated token from jupyter lab into Hydrogen settings, it works fine.

Of course, it's then much easier to set the token with --NotebookApp.token option when starting jupyterlab so that I don't have to change it in Hydrogen settings every time.

So, TLDR; it works now, thanks!

@aminya Is it intended that the interactive prompt for the token doesn't work anymore?

I checked the Hydrogen docs and they actually say that one should add the token in Hydrogen settings as I've now done, so maybe my issues were just caused by me using a deprecated functionality :)

@aminya
Copy link
Member

aminya commented May 29, 2021

I see. I will check if the token entered in the UI is not transferred to the server correctly!

@aminya
Copy link
Member

aminya commented Jun 2, 2021

I see. I will check if the token entered in the UI is not transferred to the server correctly!

This is fixed in the latest version. Hydrogen now prompts for authentication in case it could not find a session.

@fohria
Copy link

fohria commented Jun 8, 2021

Awesome, thanks again for all your work on this @aminya!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 For unexpected issues
Projects
None yet
3 participants