adk-samples
adk-samples copied to clipboard
fix issues #694: add connection timeout and improve error handling for bidi-demo WebSocket
Fixed the issue where bidi-demo would show "Connecting..." forever when the WebSocket connection failed or timed out.
Changes:
- Added 10-second connection timeout to detect failed connections
- Improved error handling in onerror handler with clearer error messages
- Enhanced onclose handler to properly handle different close codes
- Added timeout cleanup to prevent memory leaks
- Added user-friendly error messages when connection fails
- Prevented unnecessary reconnection attempts when connection times out
This ensures users get proper feedback when the server is not running or connection fails, instead of being stuck on "Connecting..." indefinitely.