fix: reduce rate limit to 5s, add 10s connection timeout
All checks were successful
Build & Push / build-and-push (push) Successful in 1m56s
All checks were successful
Build & Push / build-and-push (push) Successful in 1m56s
- Rate limit reduced from 30s to 5s for testing - WebSocket setup times out after 10s instead of hanging forever - Added connection logging Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -274,10 +274,22 @@ export default function VoiceAgentProvider({ locale, children }: VoiceAgentProvi
|
||||
|
||||
// Open WebSocket to Gemini Live API
|
||||
const wsUrl = `wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?key=${apiKey}`;
|
||||
console.log('[VoiceAgent] Connecting to WebSocket...');
|
||||
const ws = new WebSocket(wsUrl);
|
||||
wsRef.current = ws;
|
||||
|
||||
// Timeout if setup doesn't complete within 10 seconds
|
||||
const setupTimeout = setTimeout(() => {
|
||||
if (ws.readyState !== WebSocket.CLOSED) {
|
||||
console.error('[VoiceAgent] Setup timed out after 10s');
|
||||
ws.close();
|
||||
setStatus('error');
|
||||
setErrorMessage('Connection timed out. Please try again.');
|
||||
}
|
||||
}, 10_000);
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log('[VoiceAgent] WebSocket opened, sending config...');
|
||||
// Send setup message — must use "config" key per Gemini Live API spec
|
||||
ws.send(JSON.stringify({
|
||||
config: {
|
||||
@@ -314,6 +326,7 @@ export default function VoiceAgentProvider({ locale, children }: VoiceAgentProvi
|
||||
// Setup complete — Gemini sends back a setupComplete message
|
||||
if (msg.setupComplete !== undefined) {
|
||||
console.log('[VoiceAgent] Setup complete, session active');
|
||||
clearTimeout(setupTimeout);
|
||||
setStatus('active');
|
||||
trackAmplitude();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user