Skip to content

Commit ecda217

Browse files
committed
Add kernel_ws_protocol configuration option
1 parent e9bc830 commit ecda217

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

jupyter_server/base/zmqhandlers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,12 @@ def _reserialize_reply(self, msg_or_list, channel=None):
272272
return cast_unicode(smsg)
273273

274274
def select_subprotocol(self, subprotocols):
275-
selected_subprotocol = (
276-
"v1.kernel.websocket.jupyter.org"
277-
if "v1.kernel.websocket.jupyter.org" in subprotocols
278-
else None
279-
)
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
280+
selected_subprotocol = preferred_protocol if preferred_protocol in subprotocols else None
280281
# None is the default, "legacy" protocol
281282
return selected_subprotocol
282283

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)