Troubleshooting - Cognigy Documentation

Connection Issues

Client Fails to Connect

Symptom: Calling connect() or connectAndCall() throws an error or times out.
Possible Causes and Solutions:

SIP Registration Fails

Symptom: The registered event is never emitted, or the error event emits after connecting.
Possible Causes and Solutions:

Call Issues

Call Not Starting

Symptom: startCall() throws an error or doesn’t initiate a call.
Possible Causes and Solutions:

No Audio

Symptom: The call connects, but no audio is heard.
Possible Causes and Solutions:

const client = await createWebRTCClient({
    endpointUrl: 'https://your-api.com/voice-connect-config',
    pcConfig: {
      iceServers: [
        { urls: 'stun:stun.l.google.com:19302' },
        {
          urls: 'turn:your-turn-server.com:3478',
          username: 'user',
          credential: 'password'
        }
      ]
    }
});

Call Drops Unexpectedly

Symptom: The ended or failed event emits shortly after the call starts.
Possible Causes and Solutions:

Transcription Issues

Transcription Events Not Received

Symptom: The transcription event is never emitted during a call.
Possible Causes and Solutions:

Browser Issues

Click To Call Not Supported

Symptom: checkWebRTCSupport() returns { supported: false }.
Possible Causes and Solutions:

Microphone Permission Issues

Symptom: The browser prompts for microphone access but the call fails.
Possible Causes and Solutions:

Error Handling

The SDK supports two complementary approaches for catching errors.

Promise-Based

All async methods return promises. Wrap them in the try and catch blocks:

try {
  await client.connect();
  await client.startCall();
} catch (error) {
  console.error('Operation failed:', error.message);
}

Event-Based

Subscribe to the error event to catch asynchronous errors during the SDK lifecycle:

client.on('error', (error) => {
  console.error('Click To Call SDK error:', error.message);
});

Combine both approaches. The try and catch blocks capture errors from direct calls, while the error event handles asynchronous errors.

Debugging Tips

Enable Event Logging

Register listeners for all key events to trace the SDK lifecycle:

client.on('connecting', () => console.log('[WebRTC] Connecting...'));
client.on('connected', () => console.log('[WebRTC] Connected'));
client.on('registered', () => console.log('[WebRTC] Registered'));
client.on('disconnected', () => console.log('[WebRTC] Disconnected'));
client.on('answered', (s) => console.log('[WebRTC] Answered:', s.id));
client.on('ended', (s, info) => console.log('[WebRTC] Ended:', info));
client.on('failed', (s, info) => console.error('[WebRTC] Failed:', info));
client.on('error', (err) => console.error('[WebRTC] Error:', err.message));

Inspect WebRTC Internals

In Chrome, navigate to chrome://webrtc-internals/ to view detailed information about active WebRTC connections, including ICE candidates, codec negotiation, and media statistics.

Check Network Traffic

Use the browser’s DevTools Network tab to inspect WebSocket connections and verify that the SIP signaling messages are being exchanged correctly.