You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**`websocket_inactivity_timeout`**- Close WebSocket after period of inactivity in milliseconds (default: `300000`=5 minutes). Heartbeats do not count as activity. Set to `0` to disable timeout. Connection automatically reconnects when needed.
915
+
-**`websocket_heartbeat_interval`**- Interval for heartbeat/keep-alive checks in milliseconds (default: `30000`=30 seconds). Also determines how frequently inactivity timeout is checked.
914
916
-**`websocket_allowed_origins`**- List of allowed origins for WebSocket connections (security)
915
917
916
918
### Architecture
@@ -968,6 +970,7 @@ WebSocket callbacks can stream updates to the client during execution using `set
968
970
```python
969
971
import asyncio
970
972
from dash import callback, Output, Input, set_props, ctx
Long-running callbacks that use loops **must** check `ws.is_shutdown` to detect when the WebSocket connection has closed. Without this check:
1003
+
- Callbacks continue running after the client disconnects, wasting server resources
1004
+
-`set_props` calls go to a closed connection and are lost
1005
+
- The callback result is never delivered to the client
1006
+
1007
+
Only "persistent callbacks" (callbacks with no Output and no Input that use only `set_props`) are automatically restarted when the WebSocket reconnects. Regular callbacks with outputs are not restarted.
1008
+
994
1009
**API:**
995
1010
-`set_props(component_id, props_dict)`- Stream prop updates immediately to client
996
1011
-`ctx.websocket`- Get WebSocket interface (returns `None`ifnotinWS context)
1012
+
-`ws.is_shutdown`- Check if the WebSocket connection has been closed
997
1013
-`await ws.get_prop(component_id, prop_name)`- Read current prop value from client
998
1014
-`await ws.set_prop(component_id, prop_name, value)`- Set single prop (async version)
999
1015
-`await ws.close(code, reason)`- Close the WebSocket connection
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
9
9
- [#3669](https://github.com/plotly/dash/pull/3669) Selection for DataTable cleared with custom action settings
10
10
- [#3680](https://github.com/plotly/dash/pull/3680) Added `search_order` prop to `Dropdown` to allow users to preserve original option order during search
11
11
- Added `csrf_token_name` and `csrf_header_name` config options to allow configuring the CSRF cookie and header names. Fixes [#729](https://github.com/plotly/dash/issues/729)
- [#3523](https://github.com/plotly/dash/pull/3523) Fall back to background callback function names if source cannot be found
13
14
- [#3785](https://github.com/plotly/dash/pull/3785) Fix patch with dcc.Graph figure.
14
15
- [#3785](https://github.com/plotly/dash/pull/3785) Fix dcc.Graph not sending duplicate clicks because it had the same payload by adding a timestamp in the click event object.
0 commit comments