- Start Jupyter hub from here jupyterhub/jupyterhub-deploy-docker: Reference deployment of JupyterHub with docker (github.com)
- Connect to Jupyter Hub from the browser for user
admin
- Spawn a server and created a token using the
Hub Panel
- At this point we’re able to create Notebooks and start kernels/execute code, everything works
- Open Postman and create a new Jupyter Session with the URL
http://localhost:8000/user/admin/api/sessions
and JSON payload as
{"path":"sample.ipynb","kernel":{"name":"python3"},"name":"sample.ipynb","type":"notebook"}
and provide the token as auth header.
The response is a status of 201 and here’s the JSON result sent back
{
"id": "d3ed6681-877d-4f03-9d78-8232616d4cc3",
"path": "sample.ipynb",
"name": "sample.ipynb",
"type": "notebook",
"kernel": {
"id": "30fa12d7-9448-4189-b496-ffb0e11869a2",
"name": "python3",
"last_activity": "2024-07-29T00:43:27.178067Z",
"execution_state": "starting",
"connections": 0
},
"notebook": {
"path": "sample.ipynb",
"name": "sample.ipynb"
}
}
Attempt to connect to the above Kernel WebSocket using node.js or the like (outside the browser), and we get a 403 error.
Here’s the sample (details might not match above response) Url for the WebSocket (which container the token as well):
ws://localhost:8000/user/admin/api/kernels/4323f636-f3db-4e01-834f-27f49cd80d09/channels?session_id=f704194e-5ba3-4508-abbe-b062a0e1cde3&token=6bb55cbea7054d92a2a40e146fff86c2
I suspect this has something to do with some configuration settings in Jupyter Lab spawned within the container. Not sure.
I’ve also tried adding the following config into the jupyterhub_config.py
file, without any luck
c.DockerSpawner.args = [
"--debug",
"--ServerApp.allow_origin='*'",
"--ServerApp.allow_remote_access=True",
]