My socket connection closes after some time, for a reason unknown to me. I used your client-js-sdk and the example in the demo repository
const webClient = new RetellWebClient();
export default function Home() {
const [ callActive, setCallActive ] = useState<boolean>(false);
useEffect(() => {
// Setup event listeners
webClient.on("conversationStarted", () => {
console.log("conversationStarted");
});
webClient.on("audio", (audio: Uint8Array) => {
console.log("There is audio");
});
webClient.on("conversationEnded", ({ code, reason }) => {
console.log("Closed with code:", code, ", reason:", reason);
setCallActive(false); // Update button to "Start" when conversation ends
});
webClient.on("error", (error) => {
console.error("An error occurred:", error);
setCallActive(false); // Update button to "Start" in case of error
});
webClient.on("update", (update) => {
// Print live transcript as needed
console.log("update", update);
});
}, []);
const toggleConversation = async () => {
if (callActive) {
webClient.stopConversation();
} else {
const registerCallResponse = await registerCall();
if (registerCallResponse.call_id) {
webClient
.startConversation({
callId: registerCallResponse.call_id,
sampleRate: 24000,
enableUpdate: true,
})
.catch(console.error);
setCallActive(true); // Update button to "Stop" when conversation starts
}
}
};
const registerCall = async (): Promise<{ call_id: string }> => {
const res = await axios.post<{ call_id: string }>("http://my-server.com/api/v1/calls/register-call/", {
audio_encoding: "s16le",
audio_websocket_protocol: "web",
sample_rate: 24000
});
return res.data;
}
...
}

My socket connection closes after some time, for a reason unknown to me. I used your
client-js-sdkand the example in thedemorepository