Closed epignot closed 10 months ago
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
Hi @epignot - thank you for opening this issue along with your great analysis. I think we must go with the proposed fix at this time since both EG is running on server 1.x and JKG is still based on notebook. I'm assuming that once the gateways are built on Jupyter Server 2.x, we'd be okay opening things back up, although I'm not confident about that statement either.
Description
Jupyter server accepts
v1.kernel.websocket.jupyter.org
ws subprotocol regardless of what support the gateway and without informing it. Notebook client ends up with websocket messages not respecting the subprotocol accepted.Reproduce
pip install --upgrade jupyter_enterprise_gateway
jupyter enterprisegateway
pip install --upgrade jupyterlab
jupyter lab --debug --GatewayClient.url="http://127.0.0.1:8888"
JupyterLab client fails to parse the messages :
In the network panel, if you look at websocket connections for requests
api/kernels/{kernel-id}/channels
, in the response headers you will notice Jupyter Server acceptedv1.kernel.websocket.jupyter.org
protocolBut when inspecting the messages, responses are actually json-serialized
Expected behavior
v1.kernel.websocket.jupyter.org
subprotocol when using theGatewayClient
Explanation
Jupyter Server now supports the websocket subprotocol
v1.kernel.websocket.jupyter.org
in addition of the legacy one. If a notebook client specifies it during in theUpgrade
request, Jupyter Server will accept thev1.kernel.websocket.jupyter.org
subprotocol by default, and it will become theKernelWebsocketHandler
'sselected_subprotocol
from tornado code:But in
GatewayWebSocketConnection
, ws connection is opened without specifying any protocols:Hence, the legacy protocol is used. I guess it's ok since the gateway
WebSocketChannelsHandler
just send messages back to the notebook clientWorkaround
Run jupyter lab with option
--GatewayWebSocketConnection.kernel_ws_protocol=""
Proposed fix
Force the websocket subprotocol for the gateway client:
This seems the simplest solution to me for now. (and that works) I don't know how Jupyter Server could be aware of the gateway protocol support before the negotiation with notebook client. Or if we should make the gateway client support the new protocol.
I will create the PR, if this fix is accepted
Context