jupyterhub / jupyter-server-proxy

Jupyter notebook server extension to proxy web services.
https://jupyter-server-proxy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
347 stars 148 forks source link

Configurable websocket settings for arbitrary proxying #493

Open Inveracity opened 2 months ago

Inveracity commented 2 months ago

Background

I'm facing an issue where arbitrary proxying to apps running in JupyterLab (ie. mylab.local/user/xyz/proxy/8080) hits the 10 MB websocket message size limit and kills the connection. I found the problem was caused by the jupyter-server-proxy and by changing the code (see diff below) from using Tornados default setting to hardcoding 1000 * 1024 * 1024 resolved the limitation.

https://github.com/jupyterhub/jupyter-server-proxy/blob/main/jupyter_server_proxy/websocket.py#L52-L54

-max_message_size=getattr(
-    websocket, "_default_max_message_size", 10 * 1024 * 1024
-),
+max_message_size=1000 * 1024 * 1024,

I am now reasoning that the raw_socket_proxy setting would bypass this limitation entirely, however it does not seem obvious to me how I can tell JupyterLab to configure the jupyter-server-proxy to default to a raw_socket_proxy? I can't find anything in the documentation on whether this is possible hence requesting the change below.

Proposed change

For arbitrary proxying in JupyterLab, it would be nice to be able to tell JupyterLab to use raw_socket_proxy via the jupyterlab config.

Example:

# jupyter_lab_config.py
c.ProxyServer.raw_socket_proxy = True

Alternative options

Or even overriding the websocket message size limit

# jupyter_lab_config.py
c.ProxyServer.websocket_message_size = 1000 * 1024 * 1024

Who would use this feature?

Anyone using jupyter-server-proxy in JupyterLab to run web apps.

Thanks for your consideration