This project demonstrates how to initiate a Tableau data source refresh from the backend via WebSockets, allowing real-time updates in a frontend application with the Tableau Embedded Dashboard.
Imagine a scenario where a user submits new data or parameters through a backend process. Once the underlying database completes saving this data, it's vital for these corresponding changes to be instantly reflected in the frontend visualizations. Our solution facilitates such real-time updates by using WebSockets, ensuring that users always view the most recent data without manual refreshes.
Each frontend client is uniquely identified with a UUID provided by the backend upon connection. This distinct identification enables specific targeting for refresh events, ensuring that only the relevant clients receive the updates.
- Make sure you have Node.js installed.
- Clone this repository.
- Navigate to the project directory and run
npm install
to install required dependencies. - Start the server using
node server.js
. It should start onhttp://localhost:3000
. - Open your browser and navigate to
http://localhost:3000
to see the embedded Tableau visualization and the "Simulate Backend Refresh" button. - Click the button to simulate a backend data update and observe the Tableau visualization refresh.
There is a switch in the backend code labeled BROADCAST_TO_ALL
. Setting this to true
will broadcast refresh events to all connected clients. Setting it to false
will only send the refresh to specifically marked clients.
- Establishes a WebSocket connection to the backend.
- Receives a unique UUID from the server, ensuring distinct session identification.
- Listens for
refresh
events from the server and updates the Tableau visualization accordingly. - Features a button to simulate a backend-triggered data refresh.
- Efficiently serves the static frontend files.
- Maintains an active list of connected WebSocket clients and their respective UUIDs.
- Provides an endpoint to trigger specific client refresh events based on their UUIDs.
- Broadcasts
refresh
messages to the appropriate clients.
-
Issue: Error related to WebSocket connection.
- Solution: Make sure the server is running and reachable at the mentioned address (
http://localhost:3000
).
- Solution: Make sure the server is running and reachable at the mentioned address (
-
Issue: Tableau visualization doesn't refresh as expected.
- Solution: Check if the frontend receives the
refresh
WebSocket message. Review the browser's console for potential error messages.
- Solution: Check if the frontend receives the