Discussions

Ask a Question
Back to all

Avatar Stops Responding After Few Interactions – “session state wrong: closed” Error

I'm encountering a recurring issue while using the streaming.task API for avatar conversations. After the avatar answers a few questions, it suddenly stops listening/responding. Upon inspecting the console and network tab, here's what I found:

POST https://api.heygen.com/v1/streaming.task 400 (Bad Request)

sendText
recognition.onresult

API Response: {code: 10005, message: 'session state wrong: closed'}
WebSocket closed.

{
"code": 10005,
"message": "session state wrong: closed"
}

This happens consistently after a few interactions. It appears that the WebSocket connection closes unexpectedly, even though the user hasn't ended the session manually. As a result, the avatar stops mid-session and cannot respond further.

I'd really appreciate it if you could look into this. Please let me know if there's a workaround, or whether I'm missing any required session handling logic on my end.