FZJ-JSC / jupyter-xprahtml5-proxy

Jupyter extensions for running a Xpra Session proxy
BSD 3-Clause "New" or "Revised" License
12 stars 9 forks source link

Jupyterlab > 4 support #6

Open satary opened 5 days ago

satary commented 5 days ago

Hi! Thanks for the extension. Do you know if it is possible to use the extension with the current jupyterlab? If I try to enable this extension now, I get incompatibility errors.

Conflicting Dependencies:
JupyterLab              Extension      Package
>=4.1.6 <4.2.0          >=2.0.0 <3.0.0||>=3.0.0 <4.0.0@jupyterlab/application
>=4.1.6 <4.2.0          >=2.0.0 <3.0.0||>=3.0.0 <4.0.0@jupyterlab/launcher
jhgoebbert commented 5 days ago

Hi @satary, I could not see any issues on our site with jupyter-xprahtml5-proxy v0.4.0 in combination with JupyterLab 4.2.1. But we do not need the environment.yml file for installation so I missed to update that file, too.

I will fix that.

jhgoebbert commented 5 days ago

It should be fixed now in main: https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/commit/3422920920eb600e5b39100a4690f4dfc5d2db2a

satary commented 5 days ago

Thanks for the fix. It looks like I was doing something wrong, and installation instructions are somewhat outdated. I've managed to install it by installing jupyter-server-proxy via conda first and then jupyter-xprahtml5-proxy via pip.

I am currently struggling with launching xpra via jupyterlab instances running on compute nodes (using jupyterhub with slurmspawner). Do you know if it is supposed to work?

jhgoebbert commented 4 days ago

Actually it is just this entry_point which makes jupyter-server-proxy to know about jupyter-xprahtml5-proxy: https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/main/setup.py#L34

This makes jupyter-server-proxy to run setup_xprahtml5 defined here when JupyterLab starts once: https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/main/jupyter_xprahtml5_proxy/__init__.py#L51 There it learns about the command to run (cmd) and the other settings like run it in a new browser tab if the launcher-icon is clicked.

As soon as the icon is clicked the xpra command will be started which you should ensure that it will work at your side as expected. Double check that xpra is found: https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/main/jupyter_xprahtml5_proxy/__init__.py#L10 and try to run the xpra-command manually in the JupyterLab-terminal to easily see errors Xpra might show you.

Which spawner you use on jupyterhub should not make any difference as all traffic is "tunneled" through jupyter-server-proxy as if it would be JupyterLab-traffic.

satary commented 4 days ago

Thank you for the explanation! Interestingly everything works flawlessly on the same machine (Jupyterhub->jupyterlab->proxy->xpra) But when i launch jupyterlab on another node (jupyterhub is on the headnode and lab on compute) i get could not start xprahtml5 in time. Which is weird as in jupyter_server logs I see, that xpra is launched (there are some issues, but those do not look as breaking anything)

I am a bit confused about [E 2024-06-27 08:12:25.837 ServerApp] section in logs (see below) I thought that it should forward to the jupyterhub machine, but now I do not know where to look for other logs and errors. jupyterhub has no errors or mentions of xpra and proxy whatsoever.

Thank you for your time!

Logs

[I 2024-06-27 08:10:55.531 ServerApp] 204 PUT /jhub/user/localadmin/lab/api/workspaces/default?1719475855457 (localadmin@127.0.0.1) 8.49ms
2024-06-27 08:10:56,010 cannot access python uinput module:
2024-06-27 08:10:56,011  No module named 'uinput'
2024-06-27 08:10:56,297 created unix domain socket '/tmp/xpra_sockets_1000_os1r5z9w/xpra-server,auth=none'
2024-06-27 08:10:56,343 pointer device emulation using XTest
[I 2024-06-27 08:10:56.368 ServerApp] 200 GET /jhub/user/localadmin/api/contents?content=1&hash=0&######### (localadmin@127.0.0.1) 32.99ms
2024-06-27 08:10:56,399 serving html content from '/usr/share/xpra/www'
2024-06-27 08:10:57,081 OpenGL is supported on display ':0'
2024-06-27 08:10:57,081  using 'llvmpipe (LLVM 15.0.7, 256 bits)' renderer

(Xpra:60230): Gtk-CRITICAL **: 08:10:57.112: gtk_widget_realize: assertion 'widget->priv->anchored || GTK_IS_INVISIBLE (widget)' failed
2024-06-27 08:10:57,170 Warning: webcam forwarding is disabled
2024-06-27 08:10:57,170  the virtual video directory '/sys/devices/virtual/video4linux' was not found
2024-06-27 08:10:57,170  make sure that the 'v4l2loopback' kernel module is installed and loaded
2024-06-27 08:10:57,170 found 0 virtual video devices for webcam forwarding
2024-06-27 08:10:57,171 started command '/etc/X11/Xsession true' with pid 60294
2024-06-27 08:10:57,172 started command 'xterm -fa DejaVu Sans Mono -fs 14' with pid 60295
2024-06-27 08:10:57,265 watching for applications menu changes in:
2024-06-27 08:10:57,265 xpra is ready.
2024-06-27 08:10:57,265  '/usr/share/applications'
2024-06-27 08:10:57,265  '/var/lib/snapd/desktop/applications'
2024-06-27 08:10:57,268 xpra GTK3 X11 version 3.1 64-bit
2024-06-27 08:10:57,282 Error parsing xdg menu data:
2024-06-27 08:10:57,282  ParsingError in file '/etc/xdg/menus/kde-debian-menu.menu', File not found
2024-06-27 08:10:57,283  this is either a bug in python-xdg,
2024-06-27 08:10:57,283  or an invalid system menu configuration
2024-06-27 08:10:57,418 251.5GB of system memory
2024-06-27 08:10:57,427  uid=1000 (localadmin), gid=1000 (localadmin)
2024-06-27 08:10:57,427  running with pid 60230 on Linux Ubuntu 22.04 jammy
2024-06-27 08:10:57,427  connected to X11 display :0 with 24 bit colors
[I 2024-06-27 08:10:58.655 ServerApp] 204 PUT /jhub/user/localadmin/lab/api/workspaces/default?1719475858581 (localadmin@127.0.0.1) 8.87ms
[I 2024-06-27 08:11:01.774 ServerApp] 200 GET /jhub/user/localadmin/api/sessions?1719475861706 (localadmin@127.0.0.1) 1.55ms
[I 2024-06-27 08:11:03.701 ServerApp] 200 GET /jhub/user/localadmin/api/kernels?1719475863633 (localadmin@127.0.0.1) 1.42ms
[I 2024-06-27 08:11:03.835 ServerApp] 200 GET /jhub/user/localadmin/api/terminals?1719475863642 (localadmin@127.0.0.1) 1.39ms
[I 2024-06-27 08:11:04.744 ServerApp] 200 GET /jhub/user/localadmin/api/contents/jupyterhub_slurmspawner_err_408.log?type=file&content=1&hash=1&format=text&1719475864666 (localadmin@127.0.0.1) 4.70ms
[I 2024-06-27 08:11:04.996 ServerApp] 200 GET /jhub/user/localadmin/api/sessions?1719475864698 (localadmin@127.0.0.1) 1.45ms
[I 2024-06-27 08:11:05.130 ServerApp] 200 GET /jhub/user/localadmin/api/contents/jupyterhub_slurmspawner_err_408.log/checkpoints?1719475864964 
------
lots of 200 responses not relevant to xpra
------
[W 2024-06-27 08:12:25.800 ServerApp] 500 GET /jhub/user/localadmin/xprahtml5/index.html?sharing=true (127.0.0.1): could not start xprahtml5 in time
[E 2024-06-27 08:12:25.837 ServerApp] {
      "X-Forwarded-Port": "60443",
      "Connection": "Keep-Alive",
      "X-Forwarded-Server": "morcopolo_wiki",
      "X-Forwarded-Host": "188.44.47.51:60443", 
      "X-Forwarded-For": "172.19.6.200,127.0.0.1",
      "X-Forwarded-Proto": "https,http",
      "Cookie": ...
      "Accept-Language": "en-US,en;q=0.9,ru;q=0.8",
      "Accept-Encoding": "gzip, deflate, br, zstd",
      "Referer": "https://188.44.47.51:60443/jhub/user/localadmin/lab",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-User": "?1",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "same-origin",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Ch-Ua-Platform": "\"Linux\"",
      "Sec-Ch-Ua-Mobile": "?0",
      "Sec-Ch-Ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
      "Host": "188.44.47.51:60443"
    }
[E 2024-06-27 08:12:25.838 ServerApp] 500 GET /jhub/user/localadmin/xprahtml5/index.html?sharing=true (localadmin@127.0.0.1) 90076.30ms
jhgoebbert commented 3 days ago

jupyter-server-proxy will wait for max 90 seconds ( see https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/main/jupyter_xprahtml5_proxy/__init__.py#L95 ) for a web service to become locally (from the jupyter-server's point of view) available. After this timeout it gives up and shows could not start xprahtml5 in time.

Here, at 08:10:55 Xpra is started but 90 seconds later at 08:12:25 jupyter-server-proxy still gets no answer at the socket/port where it expects the service to run. You need to check your Xpra setup first. Run and check the Xpra command manually.

satary commented 3 days ago

Thank you for the answer! I am very sorry to bother you with that problem, as it looks like the issue is in my limited knowledge.

I can run xpra and the output is the same (except that the socket folder is different).

I do not know how to debug it, I have tried to run xpra no the compute node (192.168.1.209 on a local network) using tcp (just to try to connect to it from the headnode, 192.168.1.200) xpra start --start=xterm --bind-tcp=0.0.0.0:10001 --no-daemon --html=on and I have successfully connected to it via the web browser running on the head node, so the xpra looks to be working using the tcp connection. Maybe the issue is in proxying the Linux socket from the compute node to the headnode, but I do not know where to look for logs and find issues. image

jhgoebbert commented 3 days ago

You might want to add some of Xpra's debug logs: https://github.com/Xpra-org/xpra/blob/master/docs/Usage/Logging.md

You could then change the command in https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/main/jupyter_xprahtml5_proxy/__init__.py#L66 to the command-parameters which run in the terminal for you.

And then I would recommend to change the settings step by step to the once I used in version 0.3.x - which is without using sockets but local ports: https://github.com/FZJ-JSC/jupyter-xprahtml5-proxy/blob/v0.3.5/jupyter_xprahtml5_proxy/__init__.py#L110

satary commented 2 days ago

Dear @jhgoebbert, thank you for the comments! I have managed to get it working via the linux sockets as intended. I do not know why, but for some reason on the compute node xpra started the websocket this way image I just removed ,-auth=none from the cmd template in the __init__.py and now it creates socket with the expected socket filename. Is this line auth=none redundant?