Uh oh!
There was an error while loading. Please reload this page.
[4.2] Add websocket callbacks - #3742
Conversation
Thank you for your contribution to Dash! 🎉 This PR is exempt from requiring a linked issue due to its labels. |
BSd3v
commented
Apr 14, 2026
First, I want to say that this is a great step at the flexibility of Dash and reducing network load. I have some concerns with security of the app level websockets that are currently implemented:
|
| use_async: Optional[bool] = None, | ||
| health_endpoint: Optional[str] = None, | ||
| websocket_callbacks: Optional[bool] = False, | ||
| allowed_websocket_origins: Optional[List[str]] = None, |
There was a problem hiding this comment.
Will this be able to be set as an environment variable?
There was a problem hiding this comment.
Yes, this is intended for embedded support.
T4rk1n
commented
Apr 20, 2026
KoolADE85
left a comment
There was a problem hiding this comment.
This is an awesome feature, and it's working well overall! 🎉
I left a couple comments around scalability/performance that I think we should look into.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| @property | ||
| @has_context | ||
| def get_websocket(self) -> typing.Optional[DashWebsocketCallback]: |
There was a problem hiding this comment.
Should be renamed to websocket, the get_ imply a function call but it's a property and ctx.websocket.close() is cleaner.
Fix issues related to set_props() in WebSocket callbacks
T4rk1n
commented
May 4, 2026
@KoolADE85 This is ready for another review, I implemented the threadpool for executing the websocket callbacks. |
KoolADE85
left a comment
There was a problem hiding this comment.
This is all working well on my end now 🎉
One small problem:
In a fresh virtual environment, the dash/requirements/fastapi.txt requirements were incomplete: I had to install uvicorn[standard] in order to enable websockets.
Uh oh!
There was an error while loading. Please reload this page.




Implements WebSocket-based callbacks for Dash, enabling real-time bidirectional communication between the renderer and backend. This replaces HTTP POST requests with persistent WebSocket connections for reduced latency and server-push capabilities.
Architecture
A SharedWorker maintains a single WebSocket connection shared across all browser tabs, routing messages between renderers and the server.
Usage
Use with fastapi
pip install dash[fastapi]==4.2.0rc1(when available).Example app in
wsapp.py(to be deleted before full release alongside quart_app.py)