Complete guide for debugging the Azure Voice Live SDK when running the web assistant sample.
- Open the web assistant (
npm run dev) - Check "Enable Debug Mode" in the configuration panel
- Open Browser DevTools (F12)
- Connect and start conversation - you'll see detailed logs
Console Tab:
- ✅ SDK Debug Logs: Detailed internal SDK operations
- ✅ Event Logging: All SDK events with data
- ✅ Connection States: WebSocket connection lifecycle
- ✅ Error Details: Full error stack traces
Network Tab:
- ✅ WebSocket Traffic: Real-time message inspection
- ✅ Headers: Authentication and connection details
- ✅ Timing: Connection and message latency
Sources Tab:
- ✅ Breakpoints: Set breakpoints in sample code
- ✅ Source Maps: Debug TypeScript source (not minified)
- ✅ Call Stack: Full execution path during errors
The sample has a live event stream that shows all SDK events in real-time:
- Click "Show Events" in the sample UI
- Toggle "Filter Important Events Only" to see all events
- Watch real-time SDK events with full JSON data
What you see:
[14:23:45] server.response.text.delta
{
"responseId": "resp_123",
"itemId": "item_456",
"delta": "Hello there!"
}Enable in sample:
// Already enabled in sample - check "Enable Debug Mode"
const clientOptions = {
enableDebugLogging: true // This enables SDK internal logging
};What you see in console:
🔧 Creating Voice Live client with debug mode: true
🐛 Debug mode enabled - you will see detailed SDK logs
🔍 Check Network tab for WebSocket messages
🔔 SDK Event: connected {...}
🔔 SDK Event: server.response.created {...}
- Open DevTools → Network Tab
- Filter by "WS" (WebSocket)
- Click on the WebSocket connection
- View Messages tab for real-time traffic
What you see:
// Outgoing to server
{"type": "session.update", "session": {...}}
// Incoming from server
{"type": "session.created", "session": {...}}
{"type": "response.text.delta", "delta": "Hello"}For debugging the actual SDK internals:
Step 1: Switch to Source Debugging
// In vite.config.ts, uncomment these lines:
resolve: {
alias: {
'@azure/ai-voicelive': '../../src/index.ts'
}
},
optimizeDeps: {
exclude: ['@azure/ai-voicelive']
}Step 2: Restart Dev Server
npm run devStep 3: Set Breakpoints
- Navigate to Sources tab in DevTools
- Find SDK files under
webpack://or similar - Set breakpoints in SDK source code
- Step through execution line by line
Debug Steps:
- Check Console for connection errors
- Network Tab → verify WebSocket connection attempt
- Headers → check authentication token
- Sample Events → look for 'error' or 'disconnected' events
Common Issues:
// Wrong endpoint
Error: WebSocket connection failed to wss://wrong-url.com
// Authentication failure
Error: 401 Unauthorized
// Network timeout
Error: Connection timeout after 30000msDebug Steps:
- Console → check for getUserMedia errors
- Audio Level Meter → verify microphone input
- Sample Events → look for audio buffer events
- Network Tab → verify audio data being sent
Common Issues:
// Microphone permission denied
Error: NotAllowedError: Permission denied
// Audio format issues
Warning: Audio format conversion needed
// No audio input detected
Warning: Microphone level is 0Debug Steps:
- Sample Events → filter for response events
- Console → check streaming iterator logs
- Network Tab → verify response deltas coming from server
Event Types to Watch:
server.response.created // Response started
server.response.text.delta // Text chunks
server.response.audio.delta // Audio chunks
server.response.done // Response completedDebug Steps:
- Performance Tab → record during conversation
- Memory Tab → check for memory leaks
- Console → look for timeout warnings
Metrics to Watch:
- Memory Usage: Should stay stable during long conversations
- CPU Usage: Should spike only during active processing
- WebSocket Ping: Should stay under 100ms typically
Add custom logging to track specific flows:
// In your sample code
client.events.on('server.response.text.delta', (event) => {
console.log('📝 Text Delta:', {
responseId: event.responseId,
deltaLength: event.delta.length,
timestamp: Date.now()
});
});
client.events.on('server.response.audio.delta', (event) => {
console.log('🎵 Audio Delta:', {
responseId: event.responseId,
dataSize: event.delta.byteLength,
timestamp: Date.now()
});
});Monitor SDK state in real-time:
// Add to your sample
setInterval(() => {
if (client.avatarManager) {
console.log('👤 Avatar State:', client.avatarManager.currentState);
}
console.log('🔗 Connection Status:', client.connectionStatus);
}, 5000);Track streaming performance:
let textChunkCount = 0;
let audioChunkCount = 0;
client.events.on('server.response.text.delta', () => textChunkCount++);
client.events.on('server.response.audio.delta', () => audioChunkCount++);
setInterval(() => {
console.log('📊 Streaming Stats:', {
textChunks: textChunkCount,
audioChunks: audioChunkCount,
rate: `${textChunkCount + audioChunkCount}/min`
});
textChunkCount = 0;
audioChunkCount = 0;
}, 60000);The SDK has different logging levels you can control:
// In browser console, you can also enable more detailed logging:
localStorage.setItem('AZURE_LOG_LEVEL', 'verbose');
// Then reload the page
// Available levels:
// - 'error' : Only errors
// - 'warning' : Errors + warnings
// - 'info' : Errors + warnings + info (default when debug enabled)
// - 'verbose' : Everything including internal state changesFor debugging on mobile devices:
Option 1: Remote Debugging
- Chrome DevTools → More tools → Remote devices
- Connect your phone via USB
- Debug the mobile browser from desktop
Option 2: Console Overlay
// Add to sample for mobile console
if (window.innerWidth < 768) {
const consoleDiv = document.createElement('div');
consoleDiv.style.cssText = 'position:fixed;bottom:0;left:0;right:0;height:200px;background:black;color:green;overflow:auto;font-size:10px;z-index:9999;';
document.body.appendChild(consoleDiv);
const originalConsoleLog = console.log;
console.log = (...args) => {
originalConsoleLog(...args);
consoleDiv.innerHTML += args.join(' ') + '<br>';
consoleDiv.scrollTop = consoleDiv.scrollHeight;
};
}For debugging in production environments:
Option 1: Remote Logging
// Send debug info to your logging service
const logToService = (level, message, data) => {
fetch('/api/logs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ level, message, data, timestamp: Date.now() })
});
};
// Hook into SDK events
client.events.on('error', (error) => {
logToService('error', 'Voice Live SDK Error', error);
});Option 2: User Feedback Integration
// Add debug info to user feedback
const gatherDebugInfo = () => ({
userAgent: navigator.userAgent,
connection: client.connectionStatus,
lastError: lastErrorMessage,
eventCounts: { text: textEventCount, audio: audioEventCount },
performance: {
avgLatency: averageLatency,
memoryUsage: performance.memory?.usedJSHeapSize
}
});When experiencing issues, check:
- Debug mode enabled in sample UI
- Console tab open to see SDK logs
- Network tab filtered to WebSocket traffic
- Events panel visible in sample UI
- Audio permissions granted by browser
- HTTPS connection (required for microphone)
- API key and endpoint correct
- Browser compatibility (modern browser)
When reporting issues, include:
- Browser and version
- Console logs (with debug enabled)
- Network tab screenshot (WebSocket messages)
- Sample events output (from Events panel)
- Steps to reproduce
- Expected vs actual behavior
This comprehensive debugging setup gives you full visibility into the Voice Live SDK's operation, from high-level events down to individual WebSocket messages and internal state changes!