Skip to content

Commit 54c2ea2

Browse files
authored
Merge branch 'main' into auth-by-default
2 parents 90d7044 + 62f4ca2 commit 54c2ea2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

jupyter_server/serverapp.py

+36
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ def __init__(
242242
authorizer=None,
243243
identity_provider=None,
244244
kernel_websocket_connection_class=None,
245+
websocket_ping_interval=None,
246+
websocket_ping_timeout=None,
245247
):
246248
"""Initialize a server web application."""
247249
if identity_provider is None:
@@ -279,6 +281,8 @@ def __init__(
279281
authorizer=authorizer,
280282
identity_provider=identity_provider,
281283
kernel_websocket_connection_class=kernel_websocket_connection_class,
284+
websocket_ping_interval=websocket_ping_interval,
285+
websocket_ping_timeout=websocket_ping_timeout,
282286
)
283287
handlers = self.init_handlers(default_services, settings)
284288

@@ -344,6 +348,8 @@ def init_settings(
344348
authorizer=None,
345349
identity_provider=None,
346350
kernel_websocket_connection_class=None,
351+
websocket_ping_interval=None,
352+
websocket_ping_timeout=None,
347353
):
348354
"""Initialize settings for the web application."""
349355
_template_path = settings_overrides.get(
@@ -427,6 +433,8 @@ def init_settings(
427433
"identity_provider": identity_provider,
428434
"event_logger": event_logger,
429435
"kernel_websocket_connection_class": kernel_websocket_connection_class,
436+
"websocket_ping_interval": websocket_ping_interval,
437+
"websocket_ping_timeout": websocket_ping_timeout,
430438
# handlers
431439
"extra_services": extra_services,
432440
# Jupyter stuff
@@ -1620,6 +1628,32 @@ def _default_kernel_websocket_connection_class(
16201628
return "jupyter_server.gateway.connections.GatewayWebSocketConnection"
16211629
return ZMQChannelsWebsocketConnection
16221630

1631+
websocket_ping_interval = Integer(
1632+
config=True,
1633+
help="""
1634+
Configure the websocket ping interval in seconds.
1635+
1636+
Websockets are long-lived connections that are used by some Jupyter
1637+
Server extensions.
1638+
1639+
Periodic pings help to detect disconnected clients and keep the
1640+
connection active. If this is set to None, then no pings will be
1641+
performed.
1642+
1643+
When a ping is sent, the client has ``websocket_ping_timeout``
1644+
seconds to respond. If no response is received within this period,
1645+
the connection will be closed from the server side.
1646+
""",
1647+
)
1648+
websocket_ping_timeout = Integer(
1649+
config=True,
1650+
help="""
1651+
Configure the websocket ping timeout in seconds.
1652+
1653+
See ``websocket_ping_interval`` for details.
1654+
""",
1655+
)
1656+
16231657
config_manager_class = Type(
16241658
default_value=ConfigManager,
16251659
config=True,
@@ -2206,6 +2240,8 @@ def init_webapp(self) -> None:
22062240
authorizer=self.authorizer,
22072241
identity_provider=self.identity_provider,
22082242
kernel_websocket_connection_class=self.kernel_websocket_connection_class,
2243+
websocket_ping_interval=self.websocket_ping_interval,
2244+
websocket_ping_timeout=self.websocket_ping_timeout,
22092245
)
22102246
if self.certfile:
22112247
self.ssl_options["certfile"] = self.certfile

0 commit comments

Comments
 (0)