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

Error when using CHP-py with jupyterhb #16

Open
AbdealiLoKo opened this issue Jan 25, 2023 · 11 comments
Open

Error when using CHP-py with jupyterhb #16

AbdealiLoKo opened this issue Jan 25, 2023 · 11 comments

Comments

@AbdealiLoKo
Copy link
Collaborator

I'm using this py CHP with my jupyterhub as an alternative to nodejs CHP
So, whenever, I try to open a notebook, I'm seeing the below exception in proxy logs, which is not the case for the other CHP. As a result, the notebook keeps loading

`Traceback (most recent call last):
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/websocket.py", line 1086, in write_message
    fut = self._write_frame(True, opcode, message, flags=flags)
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/websocket.py", line 1061, in _write_frame
    return self.stream.write(frame)
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/iostream.py", line 530, in write
    self._check_closed()
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/iostream.py", line 1019, 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 "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/websocket.py", line 635, in _run_callback
    result = callback(*args, **kwargs)
  File "/export/apps/python/3.10/lib/python3.10/site-packages/configurable_http_proxy/handlers.py", line 414, in on_message
    self.ws_client.write_message(message)
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/websocket.py", line 1500, in write_message
    return self.protocol.write_message(message, binary=binary)
  File "/export/apps/python/3.10/lib/python3.10/site-packages/tornado/websocket.py", line 1088, in write_message
    raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError`

Originally posted by @SMHari in #11 (comment)

@AbdealiLoKo
Copy link
Collaborator Author

AbdealiLoKo commented Jan 25, 2023

Hi @SMHari can you provide the steps to reproduce this ?

  • Which version of python, jupyterhub, notebook, etc. Which OS
  • Are you using jupyterlab or notebook ?
  • What configurations are you using in jupyterhub

I am currently using this project for a bunch of environments (Local, Dev, and Prod setups)

@SMHari
Copy link

SMHari commented Jan 25, 2023

Hey @AbdealiLoKo
Sure

  1. Using python 3.10, OSS JupyterHub is 3.1.0
  2. The setup I'm using is from z2jh in k8s (https://z2jh.jupyter.org/en/stable/)
  3. using custom authenticators and spawners, but I hope that shouldn't be the issue

@AbdealiLoKo
Copy link
Collaborator Author

Hmm, so I tried this, and it seems to work:

$ ~/python310/bin/python -m venv venvtest

$ venvtest/bin/pip install jupyterhub configurable-http-proxy jupyter
Successfully installed ... configurable-http-proxy-0.3.0 ... jupyterhub-3.1.0 ... notebook-6.5.2

$ export PATH=venvtest/bin/:$PATH

$ cat jupyterhub_config.py
import os, sys
c.ConfigurableHTTPProxy.command = [os.path.join(sys.prefix, 'bin', 'configurable-http-proxy')]
c.Spawner.cmd = [os.path.join(sys.prefix, 'bin', 'jupyterhub-singleuser')]

$ venvtest/bin/jupyterhub

opening localhost:8000 successfully opens and works fine

Could you try the same steps ?

@SMHari
Copy link

SMHari commented Jan 26, 2023

@AbdealiLoKo you mean the notebook is loading fine and can execute the contents in the cell?

also would like to understand, what's the purpose of this two configparams.

  1. c.ConfigurableHTTPProxy.command
  2. c.Spawner.cmd

I'm using a custom implementation of Spawner, a wrapper over KubeSpawner.

ConfigurableHTTPProxy.command - I don't see this option in the OSS doc. I just use the options mentioned in the wiki here running proxy separately from the hub

@AbdealiLoKo
Copy link
Collaborator Author

AbdealiLoKo commented Jan 26, 2023

Yes, I am able to login with my user account, create a folder, create a notebook, run python commands in that notebook

Both of the configurations I mentioned are JupyterHub configurations:

  • c.ConfigurableHTTPProxy.command link - The executable path to use for configurable-http-proxy
  • c.Spawner.cmd link - The executable path to use for the jupyterhub-singleuser

The default values just take it from the existing PATH:

c.ConfigurableHTTPProxy.command = 'configurable-http-proxy'
c.Spawner.cmd = 'jupyterhub-singleuser'

I just gave them explicitly to ensure it is being taken from my virtualenv (I have a lot of jupyters and configurable-http-proxy installed locally with varying versions and prefer not to muck around with my PATH)
Using separate proxy is fine too

I think it would be helpful to narrow down the problem.
So, would it be possible for you to run the same steps I mentioned above to ensure it is not an issue with your Python, OS, etc. ?
An then maybe create a minimum reproducible example to see if it is some specific issue with KubeSpawner or something else ?

@AbdealiLoKo
Copy link
Collaborator Author

I tried to go towards your setup with:

$ cat jupyterhub_config.py
import os, sys
c.ConfigurableHTTPProxy.should_start = False
c.ConfigurableHTTPProxy.auth_token = 'abc'
c.Spawner.cmd = [os.path.join(sys.prefix, 'bin', 'jupyterhub-singleuser')]

And ran the following separately:

$ CONFIGPROXY_AUTH_TOKEN=abc venvtest/bin/configurable-http-proxy

And that seems to work fine (i.e. able to login, create a notebook, run python) too

I am not very experienced with Kubernetes, and looked like it would be complex for me to setup quickly

@VitaliyFedorov
Copy link

VitaliyFedorov commented Jan 30, 2023

I have absolutly the same issue, but it's appear only when I trying to start VS Code via jupyterhub-vscode-proxy.
If I install CHP-nodejs all works fine (notebook, terminal, python, VS Code), but if CHP-py installed all fine except VS Code (jupyterhub-vscode-proxy).
May be somebody has any ideas to how to fix this or how I can investigate it.

configurable-http-proxy 0.2.3
jupyterhub 2.3.1
jupyter-vscode-proxy 0.2
jupyterlab 3.5.3
jupyter-server-proxy 3.2.2

jupyterhub published to on prem k8s cluster

c.ConfigurableHTTPProxy.should_start = False
c.ConfigurableHTTPProxy.auth_token = '<some_value_from_env_var_CONFIGPROXY_AUTH_TOKEN>'

CONFIGPROXY_AUTH_TOKEN env var passed to proxy container

@SMHari
Copy link

SMHari commented Jan 30, 2023


@AbdealiLoKo
I'm running the entire stack in k8s and seem to get my single-user pod up and running without issues.
But while opening any notebook, I'm facing the issue

Need to backtrack the stack trace to understand whether those scenarios are missing any required handling

@AbdealiLoKo
Copy link
Collaborator Author

@VitaliyFedorov thanks for the feedback. I have not seen jupyter-vscode-proxy before - I can take a look at it tomorrow to understand what could be the issue.

Meanwhile if you're able to provide a minimum reproducible example with jupyter-vscode-proxy which can reproduce your error - that would be very helpful

@AbdealiLoKo
Copy link
Collaborator Author

So, @VitaliyFedorov I took a quick look at jupyter-vscode-proxy pypi link
But I could see no documentation of what it does nor how can I set it up locally to reproduce the issue you reported

I have asked a question on the repo: betatim/vscode-binder#37
But it would be great if you can give me a reproducible example

@VitaliyFedorov
Copy link

VitaliyFedorov commented Feb 3, 2023

code-server has to be installed on jupyterlab and also following py packages: jupyter-server-proxy and jupyter-vscode-proxy. After that in jupyterlab should appear button with title "VS Code". When you press it a new tab will be open with web version of VS Code.
In opened VS Code tab websocket error appear

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

3 participants