Skip to content

Commit 8b98255

Browse files
committed
Add kernel_ws_protocol configuration option
1 parent e9bc830 commit 8b98255

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

jupyter_server/base/zmqhandlers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,14 @@ def _reserialize_reply(self, msg_or_list, channel=None):
272272
return cast_unicode(smsg)
273273

274274
def select_subprotocol(self, subprotocols):
275+
preferred_protocol = self.settings.get("kernel_ws_protocol")
276+
if preferred_protocol is None:
277+
preferred_protocol = "v1.kernel.websocket.jupyter.org"
278+
elif preferred_protocol == "":
279+
preferred_protocol = None
275280
selected_subprotocol = (
276-
"v1.kernel.websocket.jupyter.org"
277-
if "v1.kernel.websocket.jupyter.org" in subprotocols
281+
preferred_protocol
282+
if preferred_protocol in subprotocols
278283
else None
279284
)
280285
# None is the default, "legacy" protocol

jupyter_server/serverapp.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def init_settings(
314314
"no_cache_paths": [url_path_join(base_url, "static", "custom")],
315315
},
316316
version_hash=version_hash,
317+
# kernel message protocol over websoclet
318+
kernel_ws_protocol=jupyter_app.kernel_ws_protocol,
317319
# rate limits
318320
limit_rate=jupyter_app.limit_rate,
319321
iopub_msg_rate_limit=jupyter_app.iopub_msg_rate_limit,
@@ -1613,6 +1615,19 @@ def _update_server_extensions(self, change):
16131615
help=_i18n("Reraise exceptions encountered loading server extensions?"),
16141616
)
16151617

1618+
kernel_ws_protocol = Unicode(
1619+
None,
1620+
allow_none=True,
1621+
config=True,
1622+
help=_i18n(
1623+
"Preferred kernel message protocol over websocket to use (default: None). "
1624+
"If an empty string is passed, select the legacy protocol. If None, "
1625+
"the selected protocol will depend on what the front-end supports "
1626+
"(usually the most recent protocol supported by the back-end and the "
1627+
"front-end)."
1628+
),
1629+
)
1630+
16161631
limit_rate = Bool(
16171632
False,
16181633
config=True,

0 commit comments

Comments
 (0)