Fix: Replace dead PubNub Twitter stream with live WebSocket data source
๐ง Fix: Replace Dead PubNub Twitter Stream with Live WebSocket Data
๐ Issue Reference
Fixes #8
๐ Problem Analysis
The application stopped working because the PubNub Twitter stream (pubnub-twitter channel) is no longer functional. This is due to:
- Twitter API Changes (Feb 2023): Twitter/X ended free API access in February 2023, moving to a paid tier-only model
- PubNub Demo Stream: The PubNub Twitter stream was a demo service that relied on Twitter's free API, which is no longer available
- Impact: Both
index.htmlandmessages.htmlwere unable to receive real-time data, rendering the matrix visualization non-functional
โ Solution Implemented
Replaced the deprecated PubNub Twitter stream with a free, actively maintained WebSocket stream from Quixio's real-time-data-sources:
WebSocket URL: wss://ai-chat-wss-demo-realtimedatasources-prod.deployments.quix.io/timeseries
Data Source: Real-time AI-generated customer support chat conversations (using Llama2 AI agents)
๐ Changes Made
1. index.html
- โ Removed PubNub SDK dependency
- โ
Replaced
PUBNUB.init()with native WebSocket API - โ Updated message handling to parse WebSocket JSON format
- โ Added reconnection logic (auto-reload after 5 seconds on disconnect)
- โ Maintained original visual effect and character rendering
2. messages.html
- โ Removed PubNub SDK dependency
- โ
Replaced
PUBNUB.init()with native WebSocket API - โ
Updated message queue from
twitterMessagestochatMessages - โ Added reconnection logic (auto-reload after 5 seconds on disconnect)
- โ Maintained all original features (speed adjustment, mouse interaction, clickable columns)
- โ Preserved language filtering capability
๐ฏ Benefits
- Working Data Stream: Application now receives real-time data again
- No External Dependencies: Removed PubNub SDK, using native WebSocket API
- Free & Reliable: Quixio provides a free public stream for demos
- Better Resilience: Added automatic reconnection on disconnect
- Same Visual Experience: Users see the same Matrix-style falling text effect
๐งช Testing
Created test utilities in experiments/ folder:
test_websocket.html- Simple WebSocket connection testtest_server.py- Local HTTP server for testing
To test locally:
cd /path/to/repo
python3 experiments/test_server.py
# Open http://localhost:8000/index.html or http://localhost:8000/messages.html
๐ Technical Details
WebSocket Message Format:
{
"timestamps": [1234567890],
"stringValues": {
"chat": ["Customer message text here"],
"conversation_id": ["conv_123"],
"role": ["customer"]
}
}
The implementation extracts chat text from stringValues and converts it to Unicode symbols using the existing getSymbols() function, maintaining compatibility with the original visualization logic.
๐ Deployment
No special deployment steps required. The changes work with any static file hosting since WebSocket connections are made client-side.
๐ค Generated with Claude Code
Co-Authored-By: Claude [email protected]