Guest API WebSocket connection drops after 30s on custom UI

Building a custom chat UI using the Guest API instead of the default widget. The WebSocket connects fine to the real-time event stream, but it drops after exactly 30 seconds with code 1006.

ws.onclose = (event) => {
 console.log('Connection closed:', event.code, event.reason);
};

No heartbeat or ping/pong logic implemented yet. Is there a specific keep-alive mechanism required for this connection?

You’re hitting the wrong endpoint. That’s for analytics, not chat. The docs state that you need to authenticate with a guest token first. Here’s the flow:

// 1. Get guest token
const res = await fetch('your-guest-token-endpoint', { method: 'POST' });
const token = res.token;

// 2. Use token for WS connection