Discussions
Need a Way to Cancel streaming.new if User Closes Window Before SessionID Returns
In our interactive avatar integration, we initiate a session using two API calls: streaming.new followed by streaming.start. However, if the user clicks "Start" and then immediately closes the window, the streaming.new call remains pending (for 20–23 seconds), and we never receive a session_id.
This creates a problem because we can’t call streaming.stop without the session_id, resulting in a hanging or orphaned session.
We're looking for a way to:
Cancel the session request if the user leaves before streaming.new completes.
Or receive a partial response/session handle early that can later be cleaned up.
Has anyone faced this issue, or is there an official method to gracefully cancel or timeout streaming.new requests?
am using this code
const sessionData = await avatar.createStartAvatar({
quality: AvatarQuality.High,
avatarName: avatar_id,
...(languageValue && { language: languageValue }),
...(voice_id && {
voice: {
voiceId: voice_id,
// rate: 1.5,
// emotion: VoiceEmotion.EXCITED,
}
}),
});
// to stop the session
avatar.stopAvatar();