From 2c4695928b94eb32ecd167d7c55f8f611575a0f6 Mon Sep 17 00:00:00 2001 From: Emmanuel Pignot Date: Wed, 9 Aug 2023 09:40:50 +0200 Subject: [PATCH] Force legacy ws subprotocol when using gateway Currently, ws subprotocols should be the same for notebook client and gateway since there is no serializer/deserializer between the 2 streams if subprotocols differ. --- jupyter_server/gateway/connections.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jupyter_server/gateway/connections.py b/jupyter_server/gateway/connections.py index e06d0d0562..a438c355b3 100644 --- a/jupyter_server/gateway/connections.py +++ b/jupyter_server/gateway/connections.py @@ -12,7 +12,7 @@ from tornado.escape import json_decode, url_escape, utf8 from tornado.httpclient import HTTPRequest from tornado.ioloop import IOLoop -from traitlets import Bool, Instance, Int +from traitlets import Bool, Instance, Int, Unicode from ..services.kernels.connection.base import BaseKernelWebsocketConnection from ..utils import url_path_join @@ -30,6 +30,10 @@ class GatewayWebSocketConnection(BaseKernelWebsocketConnection): retry = Int(0) + # When opening ws connection to gateway, server already negotiated subprotocol with notebook client. + # Same protocol must be used for client and gateway, so legacy ws subprotocol for client is enforced here. + kernel_ws_protocol = Unicode("") + async def connect(self): """Connect to the socket.""" # websocket is initialized before connection