@@ -242,6 +242,8 @@ def __init__(
242
242
authorizer = None ,
243
243
identity_provider = None ,
244
244
kernel_websocket_connection_class = None ,
245
+ websocket_ping_interval = None ,
246
+ websocket_ping_timeout = None ,
245
247
):
246
248
"""Initialize a server web application."""
247
249
if identity_provider is None :
@@ -279,6 +281,8 @@ def __init__(
279
281
authorizer = authorizer ,
280
282
identity_provider = identity_provider ,
281
283
kernel_websocket_connection_class = kernel_websocket_connection_class ,
284
+ websocket_ping_interval = websocket_ping_interval ,
285
+ websocket_ping_timeout = websocket_ping_timeout ,
282
286
)
283
287
handlers = self .init_handlers (default_services , settings )
284
288
@@ -344,6 +348,8 @@ def init_settings(
344
348
authorizer = None ,
345
349
identity_provider = None ,
346
350
kernel_websocket_connection_class = None ,
351
+ websocket_ping_interval = None ,
352
+ websocket_ping_timeout = None ,
347
353
):
348
354
"""Initialize settings for the web application."""
349
355
_template_path = settings_overrides .get (
@@ -427,6 +433,8 @@ def init_settings(
427
433
"identity_provider" : identity_provider ,
428
434
"event_logger" : event_logger ,
429
435
"kernel_websocket_connection_class" : kernel_websocket_connection_class ,
436
+ "websocket_ping_interval" : websocket_ping_interval ,
437
+ "websocket_ping_timeout" : websocket_ping_timeout ,
430
438
# handlers
431
439
"extra_services" : extra_services ,
432
440
# Jupyter stuff
@@ -1620,6 +1628,32 @@ def _default_kernel_websocket_connection_class(
1620
1628
return "jupyter_server.gateway.connections.GatewayWebSocketConnection"
1621
1629
return ZMQChannelsWebsocketConnection
1622
1630
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
+
1623
1657
config_manager_class = Type (
1624
1658
default_value = ConfigManager ,
1625
1659
config = True ,
@@ -2206,6 +2240,8 @@ def init_webapp(self) -> None:
2206
2240
authorizer = self .authorizer ,
2207
2241
identity_provider = self .identity_provider ,
2208
2242
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 ,
2209
2245
)
2210
2246
if self .certfile :
2211
2247
self .ssl_options ["certfile" ] = self .certfile
0 commit comments