yuvipanda / jupyter-desktop-server

Run a Linux Desktop on a JupyterHub
BSD 3-Clause "New" or "Revised" License
46 stars 36 forks source link

Errors after user logs out #16

Open mjuric opened 4 years ago

mjuric commented 4 years ago

Hi @yuvipanda, @manics et al:

First of all, this is a great extension! I'm looking to use it for summer schools and a few classes that require running legacy X11 apps.

One UX problem I stumbled upon -- if a user logs out (by hitting 'Applications|Log out' in the XFCE GUI), that shuts down vncserver. When that happens, here's what I see on the console:

Killing Xvnc process ID 44
127.0.0.1 - - [28/Jun/2020 08:12:27] 127.0.0.1:34195: Target closed connection
127.0.0.1 - - [28/Jun/2020 08:12:27] 127.0.0.1:34195: Closed target
[E 08:12:27.250 NotebookApp] Uncaught exception GET /desktop/websockify (172.17.0.1)
    HTTPServerRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/desktop/websockify', version='HTTP/1.1', remote_ip='172.17.0.1')
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 1098, in write_message
        fut = self._write_frame(True, opcode, message, flags=flags)
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 1075, in _write_frame
        return self.stream.write(frame)
      File "/opt/conda/lib/python3.7/site-packages/tornado/iostream.py", line 546, in write
        self._check_closed()
      File "/opt/conda/lib/python3.7/site-packages/tornado/iostream.py", line 1035, in _check_closed
        raise StreamClosedError(real_error=self.error)
    tornado.iostream.StreamClosedError: Stream is closed

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 649, in _run_callback
        result = callback(*args, **kwargs)
      File "/opt/conda/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py", line 86, in on_message
        self.ws.write_message(message, binary=isinstance(message, bytes))
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 1506, in write_message
        return self.protocol.write_message(message, binary=binary)
      File "/opt/conda/lib/python3.7/site-packages/tornado/websocket.py", line 1100, in write_message
        raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
Wrapped command exited (or daemon). Returned 0
In exit
Closing socket listening at :5901

More problematically, the next time the user tries to start the desktop (by clicking 'New|desktop' in Jupyter), the notebook server seems unaware that vncserver has exited:

[I 08:12:57.125 NotebookApp] Client sent subprotocols: ['binary']
[I 08:12:57.127 NotebookApp] Trying to establish websocket connection to ws://localhost:5901/websockify
[E 08:12:57.134 NotebookApp] Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7fad5f24ec90>>, <Task finished coro=<ProxyHandler.proxy_open.<locals>.start_websocket_connection() done, defined at /opt/conda/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py:307> exception=OSError(99, 'Cannot assign requested address')>)
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/tcpclient.py", line 143, in on_connect_done
        stream = future.result()
    tornado.iostream.StreamClosedError: Stream is closed

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
        ret = callback()
      File "/opt/conda/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
        future.result()
      File "/opt/conda/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py", line 313, in start_websocket_connection
        subprotocols=self.subprotocols)
      File "/opt/conda/lib/python3.7/site-packages/tornado/iostream.py", line 1226, in connect
        self.socket.connect(address)
    OSError: [Errno 99] Cannot assign requested address

(and vnclite just hangs waiting to connect).

Can you tell what's going on here? I have zero experience with coding tornado apps and Jupyter extensions (a lot with scientific python, though), but I'm willing to try to develop a fix it if you can point me in the right direction.

mjuric commented 4 years ago

FWIW, a workaround is to simply delete:

/usr/share/applications/xfce4-session-logout.desktop

(making the 'Log Out' menu option go away). But a) that's not the only way to log out, and b) being able to log out and shut down all GUI apps is sometimes advantageous from the PoV of managing resources.