Skip to main content
Triggered when the WebSocket connection is closed by the server or due to an error.

Event Properties

type
string
Event type. Always "conversation.connected.close" for this event.
message
string
Optional message describing the reason for connection closure.Example: "Connection closed by server" or "Session timeout"
{
  "type": "conversation.connected.close",
  "message": "Connection closed by server"
}

Usage Example

const NavTalkMessageType = Object.freeze({
    CONNECTED_CLOSE: "conversation.connected.close",
    // ... other event types
});

async function handleReceivedMessage(data) {
    switch (data.type) {
        case NavTalkMessageType.CONNECTED_CLOSE:
            const closeMessage = data.message || "Connection closed";
            console.log("Connection closed:", closeMessage);
            // Clean up resources
            await cleanupResources();
            stopRecording();
            break;
    }
}
This event may also be received through the WebSocket’s onclose event handler. Handle both cases appropriately.