Conversation
|
Thank you for your contribution to Dash! 🎉 This PR is exempt from requiring a linked issue due to its labels. |
|
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.
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.
|
|
||
| @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
|
@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.




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)